Revert "Revert "modify twitter auth to fail if mismatch between selected user and current user""
This reverts commit df335b0087
.
This commit is contained in:
@ -109,26 +109,32 @@ passport.use(
|
|||||||
} else {
|
} else {
|
||||||
User.findOne({ twitter: profile.id }, function(err, existingUser) {
|
User.findOne({ twitter: profile.id }, function(err, existingUser) {
|
||||||
if (err) { return done(err); }
|
if (err) { return done(err); }
|
||||||
var user = existingUser || new User();
|
if (!existingUser || (existingUser && existingUser.twitter == profile.id)) {
|
||||||
user.twitter = profile.id;
|
var user = existingUser || new User();
|
||||||
user.email = user.email || '';
|
user.twitter = profile.id;
|
||||||
user.tokens.push({
|
user.email = user.email || '';
|
||||||
kind: 'twitter',
|
user.tokens.push({
|
||||||
accessToken: accessToken,
|
kind: 'twitter',
|
||||||
tokenSecret: tokenSecret
|
accessToken: accessToken,
|
||||||
});
|
tokenSecret: tokenSecret
|
||||||
user.profile.name = user.profile.name || profile.displayName;
|
});
|
||||||
user.profile.username = user.profile.username || profile.username;
|
user.profile.name = user.profile.name || profile.displayName;
|
||||||
|
user.profile.username = user.profile.username || profile.username;
|
||||||
|
|
||||||
user.profile.location =
|
user.profile.location =
|
||||||
user.profile.location || profile._json.location;
|
user.profile.location || profile._json.location;
|
||||||
user.profile.picture =
|
user.profile.picture =
|
||||||
user.profile.picture || profile._json.profile_image_url_https;
|
user.profile.picture || profile._json.profile_image_url_https;
|
||||||
|
|
||||||
user.save(function(err) {
|
user.save(function (err) {
|
||||||
if (err) { return done(err); }
|
if (err) {
|
||||||
done(null, user);
|
return done(err);
|
||||||
});
|
}
|
||||||
|
done(null, user);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return done("Sorry, we experienced an error. This has been reported. Try logging in with a different authentication method.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user