后端移除AuthAdmin中间件

This commit is contained in:
2024-08-30 12:46:07 +08:00
parent 50f01ec49d
commit a4953bafb3

View File

@@ -1,17 +0,0 @@
import { Request, Response, NextFunction } from "express";
import config from "../../config";
import ServerStdResponse from "../../ServerStdResponse";
import Logger from "../Logger";
const logger = new Logger("AuthAdmin");
const AuthAdmin = (req: Request, res: Response, next: NextFunction) => {
let token = req.headers.authorization;
if (token === config.adminToken) {
next();
} else {
let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.ip;
logger.info(`API[${req.method}][${req.url.split('?')[0]}] 请求鉴权不通过[${token}][${ip}]`);
res.json(ServerStdResponse.AUTH_ERROR);
}
}
export default AuthAdmin;