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)