add user restriction
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from src.app.config import settings
|
||||
from typing import Optional
|
||||
from datetime import timedelta, datetime, timezone
|
||||
from argon2 import PasswordHasher
|
||||
from argon2.exceptions import (
|
||||
@@ -10,6 +11,7 @@ import jwt
|
||||
from jwt.exceptions import InvalidTokenError
|
||||
|
||||
|
||||
|
||||
password_hasher = PasswordHasher()
|
||||
|
||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
@@ -28,6 +30,11 @@ def create_access_token(data: dict):
|
||||
encoded_jwt = jwt.encode(to_encode, settings.SECRET_KEY, algorithm=settings.ALGORITHM)
|
||||
return encoded_jwt
|
||||
|
||||
#def create_refresh_token(data: dict) -> str:
|
||||
def verify_token(token: str, token_type: str = "access") -> Optional[dict]:
|
||||
try:
|
||||
payload = jwt.decode(jwt = token, key = settings.SECRET_KEY, algorithms = [settings.ALGORITHM])
|
||||
return payload
|
||||
except InvalidTokenError:
|
||||
return None
|
||||
|
||||
#def verify_token(token: str, token_type: str = "access") -> Optional[dict]:
|
||||
#def create_refresh_token(data: dict) -> str:
|
||||
Reference in New Issue
Block a user