Revert "start adding error handling to passport"

This reverts commit 89ee552a12.
This commit is contained in:
Michael Q Larson
2015-03-22 22:23:46 -07:00
parent 816f22260b
commit 6c929b8375

View File

@ -30,7 +30,6 @@ passport.use(new LocalStrategy({ usernameField: 'email' }, function(email, passw
if (err) { return done(err); }
if (!user) return done(null, false, { message: 'Email ' + email + ' not found'});
user.comparePassword(password, function(err, isMatch) {
if (err) { return done(err); }
if (isMatch) {
return done(null, user);
} else {
@ -60,7 +59,6 @@ passport.use(new LocalStrategy({ usernameField: 'email' }, function(email, passw
passport.use(new FacebookStrategy(secrets.facebook, function(req, accessToken, refreshToken, profile, done) {
if (req.user) {
User.findOne({ facebook: profile.id }, function(err, existingUser) {
if (err) { return done(err); }
if (existingUser) {
req.flash('errors', { msg: 'There is already a Facebook account that belongs to you. Sign in with that account or delete it, then link it with your current account.' });
done();
@ -82,10 +80,8 @@ passport.use(new FacebookStrategy(secrets.facebook, function(req, accessToken, r
});
} else {
User.findOne({ facebook: profile.id }, function(err, existingUser) {
if (err) { return done(err); }
if (existingUser) return done(null, existingUser);
User.findOne({ email: profile._json.email }, function(err, existingEmailUser) {
if (err) { return done(err); }
if (existingEmailUser) {
req.flash('errors', { msg: 'There is already an account using this email address. Sign in to that account and link it with Facebook manually from Account Settings.' });
done();
@ -99,7 +95,8 @@ passport.use(new FacebookStrategy(secrets.facebook, function(req, accessToken, r
user.profile.picture = 'https://graph.facebook.com/' + profile.id + '/picture?type=large';
user.profile.location = (profile._json.location) ? profile._json.location.name : '';
user.save(function(err) {
if (err) { return done(err); }
done(err, user);
});
var transporter = nodemailer.createTransport({
service: 'Mandrill',
auth: {
@ -121,9 +118,7 @@ passport.use(new FacebookStrategy(secrets.facebook, function(req, accessToken, r
].join('')
};
transporter.sendMail(mailOptions, function(err) {
if (err) { return done(err); }
done(null, user);
});
if (err) { return err; }
});
}
});