hapi-auth-bearer-mw
Advanced tools
Comparing version
@@ -64,6 +64,8 @@ (function() { | ||
credentials = { | ||
id: infoResult.actor.actorId, | ||
id: infoResult.actor.actorId.toString(), | ||
_id: infoResult.actor.actorId.toString(), | ||
clientId: infoResult.clientId, | ||
isValid: !!infoResult.isValid, | ||
isClientValid: !!infoResult.isClientValid, | ||
isAnonymous: false, | ||
scopes: scopes, | ||
@@ -75,33 +77,24 @@ scope: scopes, | ||
}; | ||
return internals.users().get(credentials.id, {}, function(err, user) { | ||
return internals.users().get(credentials.id, {}, function(err, userResult) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
credentials.name = user.username; | ||
credentials.user = user; | ||
if (_.isArray(user.roles)) { | ||
credentials.roles = user.roles; | ||
/* | ||
If user is not found, we need to return an unauthorized error | ||
*/ | ||
if (!userResult) { | ||
return cb(null, null); | ||
} | ||
if (_.isFunction(userResult.toObject)) { | ||
userResult = userResult.toObject(); | ||
} | ||
userResult._id = userResult._id.toString(); | ||
credentials.name = userResult.username; | ||
credentials.user = userResult; | ||
if (_.isArray(userResult.roles)) { | ||
credentials.roles = userResult.roles; | ||
} | ||
return cb(null, credentials); | ||
}); | ||
/* | ||
if (!info) { | ||
return cb(null, null); | ||
} | ||
info.isValid = !!(info.actor && info.actor.actorId && info.expiresIn); | ||
if (info.isValid) { | ||
user = { | ||
isServerToken: false, | ||
isActsAsActorId: false, | ||
username: info.actor.actorId, | ||
userId: info.actor.actorId, | ||
scopes: [] | ||
}; | ||
_.extend(user, info); | ||
user.scopes.push('user'); | ||
return cb(null, user); | ||
} else { | ||
return cb(null, null); | ||
*/ | ||
}); | ||
@@ -108,0 +101,0 @@ }; |
{ | ||
"name": "hapi-auth-bearer-mw", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"private": false, | ||
@@ -17,6 +17,6 @@ "main": "lib/index.js", | ||
"boom": ">=2.5.1", | ||
"underscore": ">=1.6.0" | ||
"underscore": ">=1.7.0" | ||
}, | ||
"peerDependencies": { | ||
"hapi": ">=6.5.0" | ||
"hapi": ">=6.5.0 <8" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
@@ -8,2 +8,3 @@ [](https://travis-ci.org/codedoctor/hapi-auth-bearer-mw) | ||
[](http://hapijs.com) | ||
[](http://hapijs.com) | ||
[](http://coffeedoc.info/github/codedoctor/hapi-auth-bearer-mw) | ||
@@ -22,2 +23,6 @@ | ||
## Versions | ||
1.3.2 | ||
Requires the use of hapi-user-store-multi-tenant v1.1.1 or up. | ||
## See also | ||
@@ -24,0 +29,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
403245
1.17%26
13.04%62
8.77%10910
-0.06%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated