Compare commits
4 Commits
d66b9004e0
...
30140f058f
Author | SHA1 | Date | |
---|---|---|---|
30140f058f | |||
d5ba710885 | |||
6127dd8ba4 | |||
9e4bb1b99f |
@ -15,10 +15,13 @@ class TokenData(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class User(BaseModel):
|
class User(BaseModel):
|
||||||
email: Union[str, None] = None
|
id: int
|
||||||
full_name: Union[str, None] = None
|
phone: Union[int, None] = None
|
||||||
disabled: Union[bool, None] = None
|
email: str
|
||||||
|
name: Union[str, None] = None
|
||||||
|
surname: Union[str, None] = None
|
||||||
|
|
||||||
|
|
||||||
class UserInDB(User):
|
class UserInDB(User):
|
||||||
|
password: str
|
||||||
hashed_password: str
|
hashed_password: str
|
@ -42,10 +42,10 @@ def get_password_hash(password):
|
|||||||
|
|
||||||
|
|
||||||
# проблема здесь
|
# проблема здесь
|
||||||
def get_user(db: SessionLocal, email: str):
|
def get_user(db: SessionLocal, email: str, response_model=User):
|
||||||
user_with_required_email = db.query(UserDatabase).filter(UserDatabase.email == email).one()
|
user_with_required_email = db.query(UserDatabase).filter(UserDatabase.email == email).one()
|
||||||
if user_with_required_email:
|
if user_with_required_email:
|
||||||
return user_with_required_email
|
return UserInDB(user_with_required_email)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ def create_access_token(data: dict, expires_delta: Union[timedelta, None] = None
|
|||||||
return encoded_jwt
|
return encoded_jwt
|
||||||
|
|
||||||
|
|
||||||
async def get_current_user(db: SessionLocal, token: Annotated[str, Depends(oauth2_scheme)]):
|
async def get_current_user(db: SessionLocal, token: Annotated[str, Depends(oauth2_scheme)], response_model=User):
|
||||||
credentials_exception = HTTPException(
|
credentials_exception = HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
detail="Could not validate credentials",
|
detail="Could not validate credentials",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user