mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore: lib-server
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { Init, Inject, MidwayWebRouterService, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { IMidwayKoaContext, IWebMiddleware, NextFunction } from '@midwayjs/koa';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { Constants } from '../basic/constants.js';
|
||||
import { logger } from '../utils/logger.js';
|
||||
import { Constants } from '@certd/lib-server';
|
||||
import { logger } from '@certd/pipeline';
|
||||
import { AuthService } from '../modules/authority/service/auth-service.js';
|
||||
import { SysSettingsService } from '../modules/system/service/sys-settings-service.js';
|
||||
import { SysPrivateSettings } from '../modules/system/service/models.js';
|
||||
import { SysSettingsService } from '@certd/lib-server';
|
||||
import { SysPrivateSettings } from '@certd/lib-server';
|
||||
|
||||
/**
|
||||
* 权限校验
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Provide } from '@midwayjs/core';
|
||||
import { IWebMiddleware, IMidwayKoaContext, NextFunction } from '@midwayjs/koa';
|
||||
import { logger } from '../utils/logger.js';
|
||||
import { Result } from '../basic/result.js';
|
||||
import { logger } from '@certd/pipeline';
|
||||
import { Result } from '@certd/lib-server';
|
||||
|
||||
@Provide()
|
||||
export class GlobalExceptionMiddleware implements IWebMiddleware {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Config, Provide } from '@midwayjs/core';
|
||||
import { IMidwayKoaContext, NextFunction, IWebMiddleware } from '@midwayjs/koa';
|
||||
import { PreviewException } from '../basic/exception/preview-exception.js';
|
||||
import { PreviewException } from '@certd/lib-server';
|
||||
|
||||
/**
|
||||
* 预览模式
|
||||
@@ -30,15 +30,10 @@ export class PreviewMiddleware implements IWebMiddleware {
|
||||
if (url.indexOf('?') !== -1) {
|
||||
url = url.substring(0, url.indexOf('?'));
|
||||
}
|
||||
const isModify =
|
||||
url.endsWith('update') ||
|
||||
url.endsWith('delete') ||
|
||||
url.endsWith('authz');
|
||||
const isModify = url.endsWith('update') || url.endsWith('delete') || url.endsWith('authz');
|
||||
const isPreviewId = id < 1000;
|
||||
if (this.preview && isModify && isPreviewId) {
|
||||
throw new PreviewException(
|
||||
'对不起,预览环境不允许修改此数据,如需体验请添加新数据'
|
||||
);
|
||||
throw new PreviewException('对不起,预览环境不允许修改此数据,如需体验请添加新数据');
|
||||
}
|
||||
await next();
|
||||
return;
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import {
|
||||
Autoload,
|
||||
Config,
|
||||
Init,
|
||||
Inject,
|
||||
Provide,
|
||||
Scope,
|
||||
ScopeEnum,
|
||||
} from '@midwayjs/core';
|
||||
import { Autoload, Config, Init, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { IMidwayKoaContext, IWebMiddleware, NextFunction } from '@midwayjs/koa';
|
||||
import { CommonException } from '../../basic/exception/common-exception.js';
|
||||
import { CommonException } from '@certd/lib-server';
|
||||
import { UserService } from '../../modules/authority/service/user-service.js';
|
||||
import { logger } from '../../utils/logger.js';
|
||||
import { logger } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 重置密码模式
|
||||
@@ -26,9 +18,7 @@ export class ResetPasswdMiddleware implements IWebMiddleware {
|
||||
resolve() {
|
||||
return async (ctx: IMidwayKoaContext, next: NextFunction) => {
|
||||
if (this.resetAdminPasswd === true) {
|
||||
throw new CommonException(
|
||||
'1号管理员密码已修改为123456,当前为重置密码模式,无法响应请求,请关闭重置密码模式恢复正常服务'
|
||||
);
|
||||
throw new CommonException('1号管理员密码已修改为123456,当前为重置密码模式,无法响应请求,请关闭重置密码模式恢复正常服务');
|
||||
}
|
||||
await next();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user