Last active
August 29, 2015 14:19
-
-
Save BrentAureli/bc7ca2814c99b426dc9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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