handle expired token while exists in BD
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javier Segarra 2023-11-04 14:39:59 +01:00
parent 8c6eab23e5
commit b02e1f000e
1 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,16 @@
const {models} = require('vn-loopback/server/server');
module.exports = function(options) {
return function(req, res, next) {
if (!req.accessToken)
return async function(req, res, next) {
if (!req.accessToken) {
const token = req.headers.authorization;
if (!token) return next();
const accessToken = await models.AccessToken.findById(token);
if (!accessToken) return next();
return next();
}
let LoopBackContext = require('loopback-context');
let loopbackContext = LoopBackContext.getCurrentContext();