1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix plugin only receives the actual token

This commit is contained in:
KAZUHIRO ITO 2020-02-27 19:55:21 +09:00
parent 458d794f52
commit 83942c2551

View File

@ -130,7 +130,14 @@ function TokensStrategy() {
util.inherits(TokensStrategy, passport.Strategy); util.inherits(TokensStrategy, passport.Strategy);
TokensStrategy.prototype.authenticate = function(req) { TokensStrategy.prototype.authenticate = function(req) {
var self = this; var self = this;
var token = req.headers[Users.tokenHeader()]; var token = null;
if (Users.tokenHeader() === 'authorization') {
if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
token = req.headers.authorization.split(' ')[1];
}
} else {
token = req.headers[Users.tokenHeader()];
}
if (token) { if (token) {
Users.tokens(token).then(function(admin) { Users.tokens(token).then(function(admin) {
if (admin) { if (admin) {