update jwt

This commit is contained in:
2024-11-30 22:55:21 +07:00
parent 0a9cfbbf33
commit ea0ad5cd99

View File

@ -15,7 +15,15 @@ export default class JwtHelper {
app.use( app.use(
expressjwt({ expressjwt({
secret: publicKey, algorithms: ["RS256"] secret: publicKey, algorithms: ["RS256"],
getToken: function fromHeaderOrQuerystring(req): any {
if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
return req.headers.authorization.split(' ')[1];
} else if (req.query && req.query.token) {
return req.query.token;
}
return null;
},
}).unless({ path: ["/token"] }), }).unless({ path: ["/token"] }),
function (req: Request, res: Response, next: NextFunction) { function (req: Request, res: Response, next: NextFunction) {
if (!req.auth?.data.id) { if (!req.auth?.data.id) {