🐛 Fix authenticate method
This commit is contained in:
parent
80163ce994
commit
de043ddd97
2 changed files with 1 additions and 3 deletions
|
|
@ -66,7 +66,7 @@ class User(Model):
|
||||||
return pwd_context.verify(raw_password, self.password_hash)
|
return pwd_context.verify(raw_password, self.password_hash)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def authenticate_username(cls, username: str, password: str) -> Optional["User"]:
|
async def authenticate(cls, username: str, password: str) -> Optional["User"]:
|
||||||
"""Authenticate a user by username and password."""
|
"""Authenticate a user by username and password."""
|
||||||
user = await cls.filter(username=username).first()
|
user = await cls.filter(username=username).first()
|
||||||
if user and user.verify_password(password):
|
if user and user.verify_password(password):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/login")
|
||||||
|
|
||||||
class ClaimsUser(BaseModel):
|
class ClaimsUser(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
email: str
|
|
||||||
is_admin: bool
|
is_admin: bool
|
||||||
is_staff: bool
|
is_staff: bool
|
||||||
|
|
||||||
|
|
@ -70,7 +69,6 @@ def claims(token_type: TokenType, user: User, groups: List[Group] = []) -> Claim
|
||||||
sub=str(user.id),
|
sub=str(user.id),
|
||||||
user=ClaimsUser(
|
user=ClaimsUser(
|
||||||
username=user.username,
|
username=user.username,
|
||||||
email=user.email,
|
|
||||||
is_admin=user.is_admin,
|
is_admin=user.is_admin,
|
||||||
is_staff=user.is_staff,
|
is_staff=user.is_staff,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue