Skip to content

Commit

Permalink
Logout-all use the promise too now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shocoben committed Apr 15, 2016
1 parent f895b9f commit 5704f43
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,24 @@ module.exports = function(config, router, passport, user) {

router.post('/logout-all',
function (req, res, next) {
var sessionToken = util.getSessionToken(req);
if(!sessionToken) {
return next({
error: 'unauthorized',
status: 401
});
}
user.logoutUser(null, sessionToken)
//
util.getSessionTokenPromise(req, user)
.then(function(sessionToken)
{
user.logoutUser(null, sessionToken)
.then(function () {
res.status(200).json({success: 'Logged out'});
}, function (err) {
console.error('Logout-all failed');
return next(err);
});
})
.catch(function(err){
return next({
error: 'unauthorized',
status: 401
});
});
});

// Setting up the auth api
Expand Down

0 comments on commit 5704f43

Please sign in to comment.