Skip to content

Instantly share code, notes, and snippets.

@BrentAureli
Last active August 29, 2015 14:19
Show Gist options
  • Save BrentAureli/bc7ca2814c99b426dc9a to your computer and use it in GitHub Desktop.
Save BrentAureli/bc7ca2814c99b426dc9a to your computer and use it in GitHub Desktop.
router.get('/unlink/facebook', function(req, res){
var user = req.user;
user.facebook.token = null;
user.save(function(err){
if(err)
throw err;
if(!hasActiveLink(user))
res.redirect('/auth/logout');
else
res.redirect('/profile');
})
});
router.get('/unlink/google', function(req, res){
var user = req.user;
user.google.token = null;
user.save(function(err){
if(err)
throw err;
if(!hasActiveLink(user))
res.redirect('/auth/logout');
else
res.redirect('/profile');
});
});
function hasActiveLink(user){
return (user.facebook.token || user.google.token);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment