fix(auth): error 类型 + auth_service 小修复

This commit is contained in:
iven
2026-05-18 02:14:14 +08:00
parent 3aa71a94d2
commit e149a61ce6
4 changed files with 678 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ pub enum AuthError {
#[error("{0}")]
Validation(String),
#[error("{0}")]
Forbidden(String),
#[error("版本冲突: 数据已被其他操作修改,请刷新后重试")]
VersionMismatch,
}
@@ -39,6 +42,7 @@ impl From<AuthError> for AppError {
AuthError::TokenRevoked => AppError::Unauthorized,
AuthError::UserDisabled(s) => AppError::Forbidden(s),
AuthError::Validation(s) => AppError::Validation(s),
AuthError::Forbidden(s) => AppError::Forbidden(s),
AuthError::DbError(_) => AppError::Internal(err.to_string()),
AuthError::HashError(_) => AppError::Internal(err.to_string()),
AuthError::JwtError(_) => AppError::Unauthorized,