fix auth login state race

This commit is contained in:
2026-05-09 01:03:56 +08:00
parent 23ba2703b4
commit 9ca66715a4
11 changed files with 219 additions and 11 deletions

View File

@@ -28,6 +28,8 @@ pub enum PhoneAuthError {
VerifyAttemptsExceeded,
UserNotFound,
UserStateMismatch,
SmsProviderInvalidConfig(String),
SmsProviderUpstream(String),
Store(String),
PasswordHash(String),
}
@@ -88,6 +90,9 @@ impl fmt::Display for PhoneAuthError {
Self::VerifyAttemptsExceeded => f.write_str("验证码错误次数过多,请重新获取验证码"),
Self::UserNotFound => f.write_str("用户不存在"),
Self::UserStateMismatch => f.write_str("当前账号状态不允许执行该操作"),
Self::SmsProviderInvalidConfig(message) | Self::SmsProviderUpstream(message) => {
f.write_str(message)
}
Self::Store(message) | Self::PasswordHash(message) => f.write_str(message),
}
}

View File

@@ -1862,9 +1862,10 @@ impl InMemoryAuthStore {
fn map_sms_provider_error_to_phone_error(error: SmsProviderError) -> PhoneAuthError {
match error {
SmsProviderError::InvalidVerifyCode => PhoneAuthError::InvalidVerifyCode,
SmsProviderError::InvalidConfig(message) | SmsProviderError::Upstream(message) => {
PhoneAuthError::Store(message)
SmsProviderError::InvalidConfig(message) => {
PhoneAuthError::SmsProviderInvalidConfig(message)
}
SmsProviderError::Upstream(message) => PhoneAuthError::SmsProviderUpstream(message),
}
}