mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-01-12 14:54:34 +08:00
新增 备案信息配置
This commit is contained in:
parent
66eef2bc63
commit
b484c0d812
@ -5,7 +5,7 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
public/
|
||||
|
||||
data/
|
||||
*.json
|
||||
|
||||
|
@ -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",
|
||||
|
@ -43,4 +43,6 @@ export default class SystemConfig {
|
||||
zipType: number = 1;
|
||||
// 登录次数IP限制
|
||||
loginCheckIp: boolean = true;
|
||||
// 登录界面文案
|
||||
loginInfo: string = "";
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user