handle expired token while exists in BD
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8c6eab23e5
commit
b02e1f000e
|
@ -1,7 +1,16 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
module.exports = function(options) {
|
module.exports = function(options) {
|
||||||
return function(req, res, next) {
|
return async function(req, res, next) {
|
||||||
if (!req.accessToken)
|
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();
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
let LoopBackContext = require('loopback-context');
|
let LoopBackContext = require('loopback-context');
|
||||||
let loopbackContext = LoopBackContext.getCurrentContext();
|
let loopbackContext = LoopBackContext.getCurrentContext();
|
||||||
|
|
Loading…
Reference in New Issue