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