Skip to content

Commit f190af3

Browse files
committed
Update the check criteria
1 parent 38c00a6 commit f190af3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

backend/app/admin/service/auth_service.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ async def user_verify(db: AsyncSession, username: str, password: str | None) ->
4545
user = await user_dao.get_by_username(db, username)
4646
if not user:
4747
raise errors.NotFoundError(msg='用户名或密码有误')
48-
elif user.password is None or not password_verify(password, user.password):
48+
49+
if user.password is None:
4950
raise errors.AuthorizationError(msg='用户名或密码有误')
50-
elif not user.status:
51+
else:
52+
if not password_verify(password, user.password):
53+
raise errors.AuthorizationError(msg='用户名或密码有误')
54+
55+
if not user.status:
5156
raise errors.AuthorizationError(msg='用户已被锁定, 请联系统管理员')
57+
5258
return user
5359

5460
async def swagger_login(self, *, obj: HTTPBasicCredentials) -> tuple[str, User]:

0 commit comments

Comments
 (0)