修复token验证

This commit is contained in:
hanhh 2021-06-30 12:26:54 +08:00
parent 0c3b3c206e
commit ebcf8f96c8

View File

@ -19,9 +19,6 @@ export default ({ app }: { app: Application }) => {
}),
);
app.use((req, res, next) => {
if (req.url && req.path.includes('/api/login')) {
return next();
}
const data = fs.readFileSync(config.authConfigFile, 'utf8');
const headerToken = getToken(req);
if (data) {
@ -30,6 +27,9 @@ export default ({ app }: { app: Application }) => {
return next();
}
}
if (!headerToken && req.url && req.path === '/api/login') {
return next();
}
const err: any = new Error('UnauthorizedError');
err['status'] = 401;
next(err);