Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit52f1e05

Browse files
committed
updated
2 parents3983a1a +e381590 commit52f1e05

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

‎app/models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromunicodedataimportcategory
2-
fromuuidimportUUID
31
from .databaseimportBase
42
fromsqlalchemyimportTIMESTAMP,Column,ForeignKey,String,Boolean,text
53
fromsqlalchemy.dialects.postgresqlimportUUID

‎app/oauth2.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1+
importbase64
2+
fromtypingimportList
13
fromfastapiimportDepends,HTTPException,status
24
fromfastapi_jwt_authimportAuthJWT
5+
frompydanticimportBaseModel
36

47
from .importmodels
58
from .databaseimportget_db
69
fromsqlalchemy.ormimportSession
10+
from .configimportsettings
11+
12+
13+
classSettings(BaseModel):
14+
authjwt_algorithm:str=settings.JWT_ALGORITHM
15+
authjwt_decode_algorithms:List[str]= [settings.JWT_ALGORITHM]
16+
authjwt_token_location:set= {'cookies','headers'}
17+
authjwt_access_cookie_key:str='access_token'
18+
authjwt_refresh_cookie_key:str='refresh_token'
19+
authjwt_public_key:str=base64.b64decode(
20+
settings.JWT_PUBLIC_KEY).decode('utf-8')
21+
authjwt_private_key:str=base64.b64decode(
22+
settings.JWT_PRIVATE_KEY).decode('utf-8')
23+
24+
25+
@AuthJWT.load_config
26+
defget_config():
27+
returnSettings()
728

829

930
classNotVerified(Exception):

‎app/routers/auth.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
importbase64
21
fromdatetimeimporttimedelta
3-
fromtypingimportList
4-
fromurllibimportresponse
52
fromfastapiimportAPIRouter,Request,Response,status,Depends,HTTPException
6-
frompydanticimportBaseModel,EmailStr
3+
frompydanticimportEmailStr
74

85
fromappimportoauth2
96
from ..importschemas,models,utils
@@ -13,23 +10,6 @@
1310
from ..configimportsettings
1411

1512

16-
classSettings(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-
defget_config():
30-
returnSettings()
31-
32-
3313
router=APIRouter()
3414
ACCESS_TOKEN_EXPIRES_IN=settings.ACCESS_TOKEN_EXPIRES_IN
3515
REFRESH_TOKEN_EXPIRES_IN=settings.REFRESH_TOKEN_EXPIRES_IN
@@ -48,7 +28,7 @@ async def create_user(payload: schemas.CreateUserSchema, db: Session = Depends(g
4828
raiseHTTPException(
4929
status_code=status.HTTP_400_BAD_REQUEST,detail='Passwords do not match')
5030
# Hash the password
51-
payload.password=utils.hash(payload.password)
31+
payload.password=utils.hash_password(payload.password)
5232
delpayload.passwordConfirm
5333
payload.role='user'
5434
payload.verified=True

‎app/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto")
44

55

6-
defhash(password:str):
6+
defhash_password(password:str):
77
returnpwd_context.hash(password)
88

99

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp