Fix captcha and user validation order logic error (#1065)

This commit is contained in:
MicLon
2026-02-06 14:08:07 +08:00
committed by GitHub
parent c521d2ef36
commit b6875a3c37

View File

@@ -99,8 +99,6 @@ class AuthService:
"""
user = None
try:
user, days_remaining = await self.user_verify(db, obj.username, obj.password)
await load_login_config(db)
if settings.LOGIN_CAPTCHA_ENABLED:
if not obj.uuid or not obj.captcha:
@@ -112,6 +110,7 @@ class AuthService:
raise errors.CustomError(error=CustomErrorCode.CAPTCHA_ERROR)
await redis_client.delete(f'{settings.LOGIN_CAPTCHA_REDIS_PREFIX}:{obj.uuid}')
user, days_remaining = await self.user_verify(db, obj.username, obj.password)
await user_dao.update_login_time(db, obj.username)
await db.refresh(user)
access_token_data = await create_access_token(