mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-27 22:56:07 +08:00
开启jwt
This commit is contained in:
parent
2447ff21a5
commit
e376c70e7b
|
@ -65,27 +65,27 @@ export default ({ app }: { app: Application }) => {
|
||||||
|
|
||||||
app.use(bodyParser.json({ limit: '50mb' }));
|
app.use(bodyParser.json({ limit: '50mb' }));
|
||||||
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
||||||
// app.use(
|
app.use(
|
||||||
// auth(getTokenFromReq).unless({
|
auth(getTokenFromReq).unless({
|
||||||
// path: excludePath,
|
path: excludePath,
|
||||||
// }),
|
}),
|
||||||
// );
|
);
|
||||||
// app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
// if (req.url && excludePath.includes(req.path)) {
|
if (req.url && excludePath.includes(req.path)) {
|
||||||
// return next();
|
return next();
|
||||||
// }
|
}
|
||||||
// const data = fs.readFileSync(config.authConfigFile, 'utf8');
|
const data = fs.readFileSync(config.authConfigFile, 'utf8');
|
||||||
// const authHeader = getTokenFromReq(req);
|
const authHeader = getTokenFromReq(req);
|
||||||
// if (data) {
|
if (data) {
|
||||||
// const { token } = JSON.parse(data);
|
const { token } = JSON.parse(data);
|
||||||
// if (token && authHeader.includes(token)) {
|
if (token && authHeader.includes(token)) {
|
||||||
// return next();
|
return next();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// const err: any = new Error('UnauthorizedError');
|
const err: any = new Error('UnauthorizedError');
|
||||||
// err['status'] = 401;
|
err['status'] = 401;
|
||||||
// next(err);
|
next(err);
|
||||||
// });
|
});
|
||||||
app.use(config.api.prefix, routes());
|
app.use(config.api.prefix, routes());
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user