mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2026-03-13 09:31:31 +08:00
Restore captcha uuid naming in the login params (#928)
This commit is contained in:
@@ -20,7 +20,7 @@ class AuthSchemaBase(SchemaBase):
|
||||
class AuthLoginParam(AuthSchemaBase):
|
||||
"""用户登录参数"""
|
||||
|
||||
captcha_uuid: str | None = Field(None, description='验证码 UUID')
|
||||
uuid: str | None = Field(None, description='验证码 UUID')
|
||||
captcha: str | None = Field(None, description='验证码')
|
||||
|
||||
|
||||
|
||||
@@ -103,14 +103,14 @@ class AuthService:
|
||||
|
||||
await load_login_config(db)
|
||||
if settings.LOGIN_CAPTCHA_ENABLED:
|
||||
if not obj.captcha_uuid or not obj.captcha:
|
||||
if not obj.uuid or not obj.captcha:
|
||||
raise errors.RequestError(msg=t('error.captcha.invalid'))
|
||||
captcha_code = await redis_client.get(f'{settings.LOGIN_CAPTCHA_REDIS_PREFIX}:{obj.captcha_uuid}')
|
||||
captcha_code = await redis_client.get(f'{settings.LOGIN_CAPTCHA_REDIS_PREFIX}:{obj.uuid}')
|
||||
if not captcha_code:
|
||||
raise errors.RequestError(msg=t('error.captcha.expired'))
|
||||
if captcha_code.lower() != obj.captcha.lower():
|
||||
raise errors.CustomError(error=CustomErrorCode.CAPTCHA_ERROR)
|
||||
await redis_client.delete(f'{settings.LOGIN_CAPTCHA_REDIS_PREFIX}:{obj.captcha_uuid}')
|
||||
await redis_client.delete(f'{settings.LOGIN_CAPTCHA_REDIS_PREFIX}:{obj.uuid}')
|
||||
|
||||
await user_dao.update_login_time(db, obj.username)
|
||||
await db.refresh(user)
|
||||
|
||||
Reference in New Issue
Block a user