Prepare to use another auth code
This commit is contained in:
parent
8513e8610b
commit
d2c7ce453e
@ -19,8 +19,10 @@ class User(BaseModel):
|
|||||||
phone: Union[int, None] = None
|
phone: Union[int, None] = None
|
||||||
email: str
|
email: str
|
||||||
name: Union[str, None] = None
|
name: Union[str, None] = None
|
||||||
surname: Union[str, None] = None
|
surname: str
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
|
||||||
class UserInDB(User):
|
class UserInDB(User):
|
||||||
password: str
|
password: str
|
||||||
|
@ -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()
|
user_with_required_email = db.query(UserDatabase).filter(UserDatabase.email == email).one()
|
||||||
if user_with_required_email:
|
if user_with_required_email:
|
||||||
return UserInDB(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
|
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(
|
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