1
- import base64
2
1
from datetime import timedelta
3
- from typing import List
4
- from urllib import response
5
2
from fastapi import APIRouter , Request , Response , status , Depends , HTTPException
6
- from pydantic import BaseModel , EmailStr
3
+ from pydantic import EmailStr
7
4
8
5
from app import oauth2
9
6
from .. import schemas , models , utils
13
10
from ..config import settings
14
11
15
12
16
- class Settings (BaseModel ):
17
- authjwt_algorithm : str = settings .JWT_ALGORITHM
18
- authjwt_decode_algorithms : List [str ] = [settings .JWT_ALGORITHM ]
19
- authjwt_token_location : set = {'cookies' , 'headers' }
20
- authjwt_access_cookie_key : str = 'access_token'
21
- authjwt_refresh_cookie_key : str = 'refresh_token'
22
- authjwt_public_key : str = base64 .b64decode (
23
- settings .JWT_PUBLIC_KEY ).decode ('utf-8' )
24
- authjwt_private_key : str = base64 .b64decode (
25
- settings .JWT_PRIVATE_KEY ).decode ('utf-8' )
26
-
27
-
28
- @AuthJWT .load_config
29
- def get_config ():
30
- return Settings ()
31
-
32
-
33
13
router = APIRouter ()
34
14
ACCESS_TOKEN_EXPIRES_IN = settings .ACCESS_TOKEN_EXPIRES_IN
35
15
REFRESH_TOKEN_EXPIRES_IN = settings .REFRESH_TOKEN_EXPIRES_IN
@@ -48,7 +28,7 @@ async def create_user(payload: schemas.CreateUserSchema, db: Session = Depends(g
48
28
raise HTTPException (
49
29
status_code = status .HTTP_400_BAD_REQUEST , detail = 'Passwords do not match' )
50
30
# Hash the password
51
- payload .password = utils .hash (payload .password )
31
+ payload .password = utils .hash_password (payload .password )
52
32
del payload .passwordConfirm
53
33
payload .role = 'user'
54
34
payload .verified = True
0 commit comments