Google linking and unlinking works successfully now
This commit is contained in:
2
app.js
2
app.js
@ -58,7 +58,7 @@ app.get('/account', passportConf.isAuthenticated, user.getAccount);
|
||||
app.post('/account/profile', passportConf.isAuthenticated, user.postAccountProfile);
|
||||
app.post('/account/settings', passportConf.isAuthenticated, user.postAccountSettings);
|
||||
app.post('/account/delete', passportConf.isAuthenticated, user.postDeleteAccount);
|
||||
app.post('/account/unlink/:provider', passportConf.isAuthenticated, user.getOauthUnlink);
|
||||
app.get('/account/unlink/:provider', passportConf.isAuthenticated, user.getOauthUnlink);
|
||||
|
||||
app.get('/api', api.getApi);
|
||||
app.get('/api/foursquare', passportConf.isAuthenticated, passportConf.isAuthorized, api.getFoursquare);
|
||||
|
@ -156,8 +156,8 @@ exports.getOauthUnlink = function(req, res) {
|
||||
console.log('unlinking oauth2');
|
||||
var provider = req.params.provider;
|
||||
User.findById(req.user.id, function(err, user) {
|
||||
delete user[provider];
|
||||
user.tokens = _.reject(x.tokens, function(tok) { return tok.kind === 'google'; });
|
||||
user[provider] = undefined;
|
||||
user.tokens = _.reject(user.tokens, function(token) { return token.kind === 'google'; });
|
||||
user.save(function(err) {
|
||||
console.log('Successfully unlinked:', provider);
|
||||
res.redirect('/account#settings');
|
||||
|
@ -74,22 +74,22 @@ block content
|
||||
h3 Linked Accounts
|
||||
|
||||
if user.google
|
||||
p: a.text-danger(href='/auth/google') Unlink your Google account
|
||||
p: a.text-danger(href='/account/unlink/google') Unlink your Google account
|
||||
else
|
||||
p: a(href='/auth/google') Link your Google account
|
||||
|
||||
if user.facebook
|
||||
p: a.text-danger(href='/auth/facebook') Unlink your Facebook account
|
||||
p: a.text-danger(href='/account/unlink/') Unlink your Facebook account
|
||||
else
|
||||
p: a(href='/auth/facebook') Link your Facebook account
|
||||
|
||||
if user.twitter
|
||||
p: a.text-danger(href='/auth/twitter') Unlink your Twitter account
|
||||
p: a.text-danger(href='/account/unlink/') Unlink your Twitter account
|
||||
else
|
||||
p: a(href='/auth/twitter') Link your Twitter account
|
||||
|
||||
if user.github
|
||||
p: a.text-danger(href='/auth/github') Unlink your GitHub account
|
||||
p: a.text-danger(href='/account/unlink/') Unlink your GitHub account
|
||||
else
|
||||
p: a(href='/auth/github') Link your GitHub account
|
||||
|
||||
|
Reference in New Issue
Block a user