Remove attached tokenType on req.user

This commit is contained in:
Johannes Zellner
2016-06-03 12:53:11 +02:00
parent 615f875169
commit 03cd3f0b6f
-8
View File
@@ -101,23 +101,15 @@ function initialize(callback) {
// scopes here can define what capabilities that token carries // scopes here can define what capabilities that token carries
// passport put the 'info' object into req.authInfo, where we can further validate the scopes // passport put the 'info' object into req.authInfo, where we can further validate the scopes
var info = { scope: token.scope }; var info = { scope: token.scope };
var tokenType;
if (token.identifier.indexOf(tokendb.PREFIX_USER) === 0) { if (token.identifier.indexOf(tokendb.PREFIX_USER) === 0) {
tokenType = tokendb.TYPE_USER;
token.identifier = token.identifier.slice(tokendb.PREFIX_USER.length); token.identifier = token.identifier.slice(tokendb.PREFIX_USER.length);
} else {
// legacy tokens assuming a user access token
tokenType = tokendb.TYPE_USER;
} }
userdb.get(token.identifier, function (error, user) { userdb.get(token.identifier, function (error, user) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(null, false); if (error && error.reason === DatabaseError.NOT_FOUND) return callback(null, false);
if (error) return callback(error); if (error) return callback(error);
// amend the tokenType of the token owner
user.tokenType = tokenType;
// amend the admin flag // amend the admin flag
groups.isMember(groups.ADMIN_GROUP_ID, user.id, function (error, isAdmin) { groups.isMember(groups.ADMIN_GROUP_ID, user.id, function (error, isAdmin) {
if (error) return callback(error); if (error) return callback(error);