From 52d9ad3399d9a8c1fd68dc36eb616361c8ae6a9b Mon Sep 17 00:00:00 2001 From: DmitryGantimurov Date: Wed, 19 Jul 2023 23:24:42 +0300 Subject: [PATCH] Prepare to use another auth code --- back/schema.py | 4 +++- back/utils.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/back/schema.py b/back/schema.py index 2d63adc..dc71245 100644 --- a/back/schema.py +++ b/back/schema.py @@ -19,8 +19,10 @@ class User(BaseModel): phone: Union[int, None] = None email: str name: Union[str, None] = None - surname: Union[str, None] = None + surname: str + class Config: + orm_mode = True class UserInDB(User): password: str diff --git a/back/utils.py b/back/utils.py index 1b8bd01..41f4bc3 100644 --- a/back/utils.py +++ b/back/utils.py @@ -42,7 +42,7 @@ def get_password_hash(password): # проблема здесь -def get_user(db: SessionLocal, email: str, response_model=User): +def get_user(db: SessionLocal, email: str): user_with_required_email = db.query(UserDatabase).filter(UserDatabase.email == email).one() if user_with_required_email: return UserInDB(user_with_required_email) @@ -69,7 +69,7 @@ def create_access_token(data: dict, expires_delta: Union[timedelta, None] = None return encoded_jwt -async def get_current_user(db: SessionLocal, token: Annotated[str, Depends(oauth2_scheme)], response_model=User): +async def get_current_user(db: SessionLocal, token: Annotated[str, Depends(oauth2_scheme)]): credentials_exception = HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Could not validate credentials",