Compare commits

..

No commits in common. "239fa59d099f223a733927ddd632c1dbb916a6d6" and "d10f32519eb931dea18a0da864db2d379d9a9d9f" have entirely different histories.

2 changed files with 1 additions and 22 deletions

3
.gitignore vendored
View File

@ -4,5 +4,4 @@
__pycache__
**/__pycache__
static/temp/
static/chat/
static/temp/

View File

@ -6,7 +6,6 @@ from pydantic import BaseModel
from jose import ExpiredSignatureError, JWTError
from ..crud.user_crud import select_account_by
from ..utils.email_code import verify_code
from ..utils.password import verify_password
from ..utils.token_handler import (
create_signin_token,
@ -31,7 +30,6 @@ class TokenPayload(BaseModel):
async def signin_by_username(form_data: OAuth2PasswordRequestForm = Depends()):
username = form_data.username
password = form_data.password
is_existence, user = await select_account_by("username", username)
if not is_existence:
@ -45,24 +43,6 @@ async def signin_by_username(form_data: OAuth2PasswordRequestForm = Depends()):
return {"code": 10201, "msg": "Username or Password Is Incorrect"}
@router.post("/email", response_model=UserAccountResponse)
async def signin_by_email(form_data: OAuth2PasswordRequestForm = Depends()):
email = form_data.username
code = form_data.password
is_existence, user = await select_account_by("email", email)
if not is_existence:
return {"code": 10202, "msg": "The Email Has Not Been Registered"}
is_correct = verify_code(email, code)
if is_correct:
return {"code": 10200, "msg": "Sign in Successfully", "data": user.to_dict()}
else:
return {"code": 10201, "msg": "The Verification Code Is Not Correct"}
@router.post("/token", response_model=TokenCreationResponse)
async def create_token(token_payload: TokenPayload):
token = create_signin_token(**token_payload.model_dump())