Buckets:

download
raw
929 Bytes
from jose import JWTError, jwt
from passlib.context import CryptContext
from datetime import datetime, timedelta
from src.core.config.config import settings
# Password hashing
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)
def create_access_token(data: dict, expires_delta: timedelta = None):
to_encode = data.copy()
if expires_delta:
expire = datetime.utcnow() + expires_delta
else:
expire = datetime.utcnow() + timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(to_encode, settings.secret_key, algorithm=settings.algorithm)
return encoded_jwt
def has_role(user, role):
return role in user.get("roles", [])

Xet Storage Details

Size:
929 Bytes
·
Xet hash:
bee45b15a74c0e952794db9d6467b0ee7f37c202f59e97175d63a7336113f3f2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.