fix remove stray profile reference

fix findOne queries should have where filter
This commit is contained in:
Berkeley Martinez
2015-06-10 17:12:21 -07:00
parent d01a48a8c3
commit 84f2168769

View File

@ -261,7 +261,9 @@ module.exports = function(app) {
return res.redirect('/account'); return res.redirect('/account');
} }
User.findOne({ email: req.body.email }, function(err, existingEmail) { User.findOne({
where: { email: req.body.email }
}, function(err, existingEmail) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -273,7 +275,7 @@ module.exports = function(app) {
return res.redirect('/account'); return res.redirect('/account');
} }
User.findOne( User.findOne(
{ 'profile.username': req.body.username }, { where: { username: req.body.username } },
function(err, existingUsername) { function(err, existingUsername) {
if (err) { if (err) {
return next(err); return next(err);
@ -281,7 +283,7 @@ module.exports = function(app) {
var user = req.user; var user = req.user;
if ( if (
existingUsername && existingUsername &&
existingUsername.profile.username !== user.username existingUsername.username !== user.username
) { ) {
req.flash('errors', { req.flash('errors', {
msg: 'An account with that username already exists.' msg: 'An account with that username already exists.'
@ -558,7 +560,7 @@ module.exports = function(app) {
}, },
function(token, done) { function(token, done) {
User.findOne({ User.findOne({
email: req.body.email.toLowerCase() where: { email: req.body.email.toLowerCase() }
}, function(err, user) { }, function(err, user) {
if (err) { return done(err); } if (err) { return done(err); }
if (!user) { if (!user) {