后台:修改白名单

This commit is contained in:
luying
2021-12-08 17:35:23 +08:00
parent fc38485f94
commit 46108f90f2
14 changed files with 56 additions and 43 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ module.exports = () => {
if (serverId) {
let server = await ServerlistModel.findByServerId(serverId);
if (server && server.maintenance && server.maintenance.isOpen && server.maintenance.startTime < nowSeconds() && server.maintenance.endTime > nowSeconds()) {
let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip);
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid, serverId);
if (isWhiteList) {
await next();
} else {
+12
View File
@@ -0,0 +1,12 @@
import { Context } from 'egg';
module.exports = () => {
return async function parmsDecode(ctx: Context, next) {
let xRealIp = typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0];
ctx.clientIp = xRealIp||ctx.request.ip;
console.log('*****', ctx.clientIp);
await next();
};
};
+1
View File
@@ -3,6 +3,7 @@ import { UserModel } from '@db/User';
module.exports = () => {
return async function tokenParser(ctx, next) {
if (!ctx.request.body || !ctx.request.body.token) {
console.error('token not found');
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);