Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScopedUser Logout Error #103

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/auth_middleware.js
Expand Up @@ -81,7 +81,7 @@ module.exports = function(optionsOrStrategy) {
middlewareCallback= scope;
scope= undefined;
}
RequestMethods.logout.call( this, {scope:scope, request:req, response:res}, logoutHandler, function() {
RequestMethods.logout.call( this, {scope:scope, request:req, response:res}, logoutHandler, function(err) {
//Clear out the saved auth details
//TODO: this should be scope-aware.
createAuthDetails( req );
Expand All @@ -90,7 +90,7 @@ module.exports = function(optionsOrStrategy) {
traceFunction( message, {scope:scope, request:req, response:res}, linePrefix );
};

if( middlewareCallback) middlewareCallback();
if( middlewareCallback) middlewareCallback(err);
})
};

Expand Down
31 changes: 18 additions & 13 deletions lib/requestMethods.js
@@ -1,3 +1,4 @@

/*!
* Copyright(c) 2010 Ciaran Jessup <ciaranj@gmai.com>
* MIT Licensed
Expand Down Expand Up @@ -155,17 +156,21 @@ module.exports.isUnAuthenticated= function(scope) {
};

module.exports.logout= function( authContext, logoutHandler, middlewareCallback ) {
var ad= this.getAuthDetails();
ad.trace( "Logout", authContext.scope, "!!!" );
var user;
if( authContext.scope === undefined) {
user= ad.user;
delete ad.user;
ad.scopedUsers= {};
}
else {
user= ad.scopedUsers[authContext.scope].user;
delete ad.scopedUsers[authContext.scope].user;
}
logoutHandler( authContext, user, middlewareCallback );
var user, err;
var ad= this.getAuthDetails();
ad.trace( "Logout", authContext.scope, "!!!" );
if( authContext.scope === undefined) {
user= ad.user;
delete ad.user;
ad.scopedUsers= {};
}
else {
try {
user= ad.scopedUsers[authContext.scope].user;
delete ad.scopedUsers[authContext.scope].user;
} catch(error){
err= new Error('There are no user credentials associated with the scope: "' + authContext.scope + '"');
}
}
logoutHandler( authContext, user, middlewareCallback(err));
};