Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Commit

Permalink
pull fix 4
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldblanco committed Dec 14, 2017
1 parent 2d73021 commit 44f3570
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions server/controllers/users/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,22 @@ export const forgot = async function(req, res) {
// Lookup user by email
if (!req.body.email) throw new BadRequestError('Email is required')
const user = await User.findOne({email: req.body.email}).select('-salt -password')
if (!user) {
/*if (!user) {
// throw new ValidationError({email: 'No account with that email has been found'})
} else if (user.provider !== 'local') {
} else */
if (user && user.provider !== 'local') {
if (user.provider === 'google') await mailer.sendPasswordGoogle(user)
/*return res.status(400).send({
message: 'It seems like you signed up using your ' + user.provider + ' account'
})*/
} else {
} else if (user && user.provider === 'local') {
user.resetPasswordToken = token
user.resetPasswordExpires = Date.now() + 3600000 // 1 hour

const port = process.env.NODE_ENV === 'production' ? '' : `:${config.port}`
const url = `${config.protocol}://${config.host}${port}/users/reset-password/${token}`

await mailer.sendPasswordReset(user, url)
await user.save()
}

const port = process.env.NODE_ENV === 'production' ? '' : `:${config.port}`
const url = `${config.protocol}://${config.host}${port}/users/reset-password/${token}`

// await mailer.sendPasswordReset(user, url)
res.send({message: 'Password reset email sent'})
}

Expand Down

0 comments on commit 44f3570

Please sign in to comment.