Spaces:
Sleeping
Sleeping
File size: 806 Bytes
b9fb109 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from config.reuseable import (
JWTError,
jwt,
HTTPException,
status,
pwd_context,
SECRET_KEY,
ALGORITHM,
ACCESS_TOKEN_EXPIRE_MINUTES,
datetime,
timedelta,
)
def verify_password(palin_password, hashed_stored_password):
return pwd_context.verify(palin_password, hashed_stored_password)
def hash_password(password):
return pwd_context.hash(password)
def create_access_token(data: dict, expires_delta: timedelta = None):
to_encode = data.copy()
expire = datetime.utcnow() + (
expires_delta or timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
)
to_encode.update({"exp": expire})
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
def verify_token(token):
return jwt.decode(token, SECRET_KEY, algorithms=ALGORITHM)
|