mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +08:00
show friendly error when user registration is disabled
This commit is contained in:
@@ -37,6 +37,7 @@ func PrintErrorResult(c *core.Context, err *errs.Error) {
|
|||||||
"success": false,
|
"success": false,
|
||||||
"errorCode": err.Code(),
|
"errorCode": err.Code(),
|
||||||
"errorMessage": errorMessage,
|
"errorMessage": errorMessage,
|
||||||
|
"path": c.Request.URL.Path,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { defaultLanguage, allLanguages } from '../locales/index.js'
|
import { defaultLanguage, allLanguages } from '../locales/index.js'
|
||||||
|
|
||||||
|
const apiNotFoundErrorCode = 100001;
|
||||||
|
const specifiedApiNotFoundErrors = {
|
||||||
|
'/api/register.json': {
|
||||||
|
message: 'User registration is disabled'
|
||||||
|
}
|
||||||
|
};
|
||||||
const validatorErrorCode = 200000;
|
const validatorErrorCode = 200000;
|
||||||
const parameterizedErrors = [
|
const parameterizedErrors = [
|
||||||
{
|
{
|
||||||
@@ -134,6 +140,12 @@ export function getI18nOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getLocalizedError(error) {
|
export function getLocalizedError(error) {
|
||||||
|
if (error.errorCode === apiNotFoundErrorCode && specifiedApiNotFoundErrors[error.path]) {
|
||||||
|
return {
|
||||||
|
message: `${specifiedApiNotFoundErrors[error.path].message}`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (error.errorCode !== validatorErrorCode) {
|
if (error.errorCode !== validatorErrorCode) {
|
||||||
return {
|
return {
|
||||||
message: `error.${error.errorMessage}`
|
message: `error.${error.errorMessage}`
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default {
|
|||||||
},
|
},
|
||||||
'error': {
|
'error': {
|
||||||
'system error': 'System Error',
|
'system error': 'System Error',
|
||||||
|
'api not found': 'Failed to request api',
|
||||||
'incomplete or incorrect submission': 'Incomplete or incorrect submission',
|
'incomplete or incorrect submission': 'Incomplete or incorrect submission',
|
||||||
'operation failed': 'Operation failed',
|
'operation failed': 'Operation failed',
|
||||||
'nothing will be updated': 'Nothing will be updated',
|
'nothing will be updated': 'Nothing will be updated',
|
||||||
@@ -92,6 +93,7 @@ export default {
|
|||||||
'Language': 'Language',
|
'Language': 'Language',
|
||||||
'You have been successfully registered': 'You have been successfully registered',
|
'You have been successfully registered': 'You have been successfully registered',
|
||||||
'Unable to sign up': 'Unable to sign up',
|
'Unable to sign up': 'Unable to sign up',
|
||||||
|
'User registration is disabled': 'User registration is disabled',
|
||||||
'Log Out': 'Log Out',
|
'Log Out': 'Log Out',
|
||||||
'Are you sure you want to log out?': 'Are you sure you want to log out?',
|
'Are you sure you want to log out?': 'Are you sure you want to log out?',
|
||||||
'Unable to logout': 'Unable to logout',
|
'Unable to logout': 'Unable to logout',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default {
|
|||||||
},
|
},
|
||||||
'error': {
|
'error': {
|
||||||
'system error': '系统错误',
|
'system error': '系统错误',
|
||||||
|
'api not found': '接口调用失败',
|
||||||
'incomplete or incorrect submission': '提交不完整或不正确',
|
'incomplete or incorrect submission': '提交不完整或不正确',
|
||||||
'operation failed': '操作失败',
|
'operation failed': '操作失败',
|
||||||
'nothing will be updated': '没有内容更新',
|
'nothing will be updated': '没有内容更新',
|
||||||
@@ -92,6 +93,7 @@ export default {
|
|||||||
'Language': '语言',
|
'Language': '语言',
|
||||||
'You have been successfully registered': '注册成功',
|
'You have been successfully registered': '注册成功',
|
||||||
'Unable to sign up': '无法注册',
|
'Unable to sign up': '无法注册',
|
||||||
|
'User registration is disabled': '用户注册已禁用',
|
||||||
'Log Out': '退出登录',
|
'Log Out': '退出登录',
|
||||||
'Are you sure you want to log out?': '您确定是否要退出登录?',
|
'Are you sure you want to log out?': '您确定是否要退出登录?',
|
||||||
'Unable to logout': '无法退出登录',
|
'Unable to logout': '无法退出登录',
|
||||||
|
|||||||
Reference in New Issue
Block a user