新增 备案信息配置

This commit is contained in:
Suwings 2022-04-16 23:34:48 +08:00
parent 66eef2bc63
commit b484c0d812
5 changed files with 26 additions and 9 deletions

View File

@ -5,7 +5,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
public/
data/
*.json

View File

@ -1,7 +1,7 @@
{
"name": "mcsmanager-panel",
"version": "9.4.2",
"daemonVersion": "1.5.2",
"version": "9.4.3",
"daemonVersion": "1.5.3",
"description": "Distributed clustering, groupable, lightweight and out-of-the-box Minecraft server management panel",
"scripts": {
"dev": "nodemon app.js",

View File

@ -43,4 +43,6 @@ export default class SystemConfig {
zipType: number = 1;
// 登录次数IP限制
loginCheckIp: boolean = true;
// 登录界面文案
loginInfo: string = "";
}

View File

@ -47,6 +47,7 @@ router.put("/setting", validator({ body: {} }), permission({ level: 10 }), async
if (config.loginCheckIp != null) systemConfig.loginCheckIp = config.loginCheckIp;
if (config.forwardType != null) systemConfig.forwardType = Number(config.forwardType);
if (config.dataPort != null) systemConfig.dataPort = Number(config.dataPort);
if (config.loginInfo != null) systemConfig.loginInfo = String(config.loginInfo);
saveSystemConfig(systemConfig);
ctx.body = "OK";
return;

View File

@ -23,7 +23,8 @@ import Koa from "koa";
import Router from "@koa/router";
import validator from "../../middleware/validator";
import permission from "../../middleware/permission";
import { check, login, logout, register, getUserUuid, checkBanIp } from '../../service/passport_service';
import { check, login, logout, checkBanIp } from "../../service/passport_service";
import { systemConfig } from "../../setting";
const router = new Router({ prefix: "/auth" });
@ -36,25 +37,38 @@ router.post(
async (ctx: Koa.ParameterizedContext) => {
const userName = String(ctx.request.body.username);
const passWord = String(ctx.request.body.password);
if (!checkBanIp(ctx))
throw new Error("身份验证次数过多,您的 IP 地址已被锁定 10 分钟")
if (!checkBanIp(ctx)) throw new Error("身份验证次数过多,您的 IP 地址已被锁定 10 分钟");
if (check(ctx)) return (ctx.body = "Logined");
let token = login(ctx, userName, passWord);
if (token) {
ctx.body = true;
} else {
throw new Error("账号或密码错误")
throw new Error("账号或密码错误");
}
}
);
// [Public Permission]
// 退出路由
router.get("/logout",
router.get(
"/logout",
permission({ token: false, level: null }),
async (ctx: Koa.ParameterizedContext) => {
logout(ctx);
ctx.body = true;
});
}
);
// [Public Permission]
// 登录界面文案展示
router.all(
"/login_info",
permission({ token: false, level: null }),
async (ctx: Koa.ParameterizedContext) => {
ctx.body = {
loginInfo: systemConfig.loginInfo
};
}
);
export default router;