更新通知服务

This commit is contained in:
whyour
2021-09-16 21:01:29 +08:00
parent ae255ef381
commit 38a9cce6bf
5 changed files with 35 additions and 20 deletions
+8 -7
View File
@@ -47,13 +47,6 @@ export default ({ app }: { app: Application }) => {
}
}
const data = fs.readFileSync(config.authConfigFile, 'utf8');
if (data) {
const { token } = JSON.parse(data);
if (token && headerToken === token) {
return next();
}
}
if (
!headerToken &&
req.path &&
@@ -71,6 +64,14 @@ export default ({ app }: { app: Application }) => {
return next();
}
const data = fs.readFileSync(config.authConfigFile, 'utf8');
if (data) {
const { token } = JSON.parse(data);
if (token && headerToken === token) {
return next();
}
}
const err: any = new Error('UnauthorizedError');
err.status = 401;
next(err);