Browse Source
Merge pull request #1218 from colinin/auth-error-localization
feat(vben5): Increase the localization of certification
pull/1238/head
yx lin
10 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
48 additions and
2 deletions
-
apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json
-
apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json
-
apps/vben5/packages/@abp/account/src/hooks/useOAuthError.ts
|
|
|
@ -11,6 +11,14 @@ |
|
|
|
}, |
|
|
|
"qrcodeLogin": { |
|
|
|
"scaned": "Please confirm login on your phone." |
|
|
|
}, |
|
|
|
"errors": { |
|
|
|
"accountLockedByInvalidLoginAttempts": "The user account has been locked out due to invalid login attempts. Please wait a while and try again.", |
|
|
|
"accountInactive": "You are not allowed to login! Your account is inactive.", |
|
|
|
"invalidUserNameOrPassword": "Invalid username or password!", |
|
|
|
"tokenHasExpired": "The token is no longer valid!", |
|
|
|
"requiresTwoFactor": "Identity verification is required. Please select a verification method!", |
|
|
|
"shouldChangePassword": "Your password has expired. Please change it and login!" |
|
|
|
} |
|
|
|
}, |
|
|
|
"manage": { |
|
|
|
|
|
|
|
@ -11,6 +11,14 @@ |
|
|
|
}, |
|
|
|
"qrcodeLogin": { |
|
|
|
"scaned": "请在手机上确认登录." |
|
|
|
}, |
|
|
|
"errors": { |
|
|
|
"accountLockedByInvalidLoginAttempts": "由于尝试登录无效,用户帐户被锁定.请稍候再试!", |
|
|
|
"accountInactive": "您不能登录,您的帐户是无效的!", |
|
|
|
"invalidUserNameOrPassword": "用户名或密码错误!", |
|
|
|
"tokenHasExpired": "您的请求会话已过期,请重新登录!", |
|
|
|
"requiresTwoFactor": "需要验证身份,请选择一种验证方式!", |
|
|
|
"shouldChangePassword": "您的密码已失效,请修改密码后登录!" |
|
|
|
} |
|
|
|
}, |
|
|
|
"manage": { |
|
|
|
|
|
|
|
@ -1,3 +1,5 @@ |
|
|
|
import { $t } from '@vben/locales'; |
|
|
|
|
|
|
|
interface OAuthError { |
|
|
|
error: string; |
|
|
|
error_description?: string; |
|
|
|
@ -6,8 +8,36 @@ interface OAuthError { |
|
|
|
|
|
|
|
export function useOAuthError() { |
|
|
|
function formatError(error: OAuthError) { |
|
|
|
// TODO: 解决oauth消息国际化.
|
|
|
|
return error.error_description; |
|
|
|
switch (error.error_description) { |
|
|
|
// 用户名或密码无效
|
|
|
|
case 'Invalid username or password!': { |
|
|
|
return $t('abp.oauth.errors.invalidUserNameOrPassword'); |
|
|
|
} |
|
|
|
// 需要二次认证
|
|
|
|
case 'RequiresTwoFactor': { |
|
|
|
return $t('abp.oauth.errors.requiresTwoFactor'); |
|
|
|
} |
|
|
|
// 需要更改密码
|
|
|
|
case 'ShouldChangePasswordOnNextLogin': { |
|
|
|
return $t('abp.oauth.errors.shouldChangePassword'); |
|
|
|
} |
|
|
|
// Token已失效
|
|
|
|
case 'The token is no longer valid.': { |
|
|
|
return $t('abp.oauth.errors.tokenHasExpired'); |
|
|
|
} |
|
|
|
// 用户尝试登录次数太多,用户被锁定
|
|
|
|
case 'The user account has been locked out due to invalid login attempts. Please wait a while and try again.': { |
|
|
|
return $t('abp.oauth.errors.accountLockedByInvalidLoginAttempts'); |
|
|
|
} |
|
|
|
// 用户未启用
|
|
|
|
case 'You are not allowed to login! Your account is inactive.': { |
|
|
|
return $t('abp.oauth.errors.accountInactive'); |
|
|
|
} |
|
|
|
// 其他不常用的错误信息返回原始字符串
|
|
|
|
default: { |
|
|
|
return error.error_description; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
|