From 6c929b83757ebc2f13e0360ff20bb51693b5ffb6 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Sun, 22 Mar 2015 22:23:46 -0700 Subject: [PATCH] Revert "start adding error handling to passport" This reverts commit 89ee552a12e42a072bc125cec2ec77e7099dc353. --- config/passport.js | 53 +++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/config/passport.js b/config/passport.js index 9c3beb04b0..970753ce21 100644 --- a/config/passport.js +++ b/config/passport.js @@ -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,31 +95,30 @@ 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); } - var transporter = nodemailer.createTransport({ - service: 'Mandrill', - auth: { - user: secrets.mandrill.user, - pass: secrets.mandrill.password - } - }); - var mailOptions = { - to: user.email, - from: 'Team@freecodecamp.com', - subject: 'Welcome to Free Code Camp!', - text: [ - 'Greetings from San Francisco!\n\n', - 'Thank you for joining our community.\n', - 'Feel free to email us at this address if you have any questions about Free Code Camp.\n', - "And if you have a moment, check out our blog: blog.freecodecamp.com.\n", - 'Good luck with the challenges!\n\n', - '- the Volunteer Camp Counselor Team' - ].join('') - }; - transporter.sendMail(mailOptions, function(err) { - if (err) { return done(err); } - done(null, user); - }); + done(err, user); + }); + var transporter = nodemailer.createTransport({ + service: 'Mandrill', + auth: { + user: secrets.mandrill.user, + pass: secrets.mandrill.password + } + }); + var mailOptions = { + to: user.email, + from: 'Team@freecodecamp.com', + subject: 'Welcome to Free Code Camp!', + text: [ + 'Greetings from San Francisco!\n\n', + 'Thank you for joining our community.\n', + 'Feel free to email us at this address if you have any questions about Free Code Camp.\n', + "And if you have a moment, check out our blog: blog.freecodecamp.com.\n", + 'Good luck with the challenges!\n\n', + '- the Volunteer Camp Counselor Team' + ].join('') + }; + transporter.sendMail(mailOptions, function(err) { + if (err) { return err; } }); } });