Browse Source

feat(vben5): Increase the localization of certification

- 账户锁定
- 账户未启用
- 用户名或密码错误
- Token已过期
- 需要二次认证
- 密码已过期
pull/1218/head
colin 10 months ago
parent
commit
713dd9276c
  1. 8
      apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json
  2. 8
      apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json
  3. 34
      apps/vben5/packages/@abp/account/src/hooks/useOAuthError.ts

8
apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json

@ -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": {

8
apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json

@ -11,6 +11,14 @@
},
"qrcodeLogin": {
"scaned": "请在手机上确认登录."
},
"errors": {
"accountLockedByInvalidLoginAttempts": "由于尝试登录无效,用户帐户被锁定.请稍候再试!",
"accountInactive": "您不能登录,您的帐户是无效的!",
"invalidUserNameOrPassword": "用户名或密码错误!",
"tokenHasExpired": "您的请求会话已过期,请重新登录!",
"requiresTwoFactor": "需要验证身份,请选择一种验证方式!",
"shouldChangePassword": "您的密码已失效,请修改密码后登录!"
}
},
"manage": {

34
apps/vben5/packages/@abp/account/src/hooks/useOAuthError.ts

@ -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 {

Loading…
Cancel
Save