Commit ee1b86e3 authored by les's avatar les
Browse files

[fix] password recovery

parent 4fe78aa3
......@@ -184,12 +184,7 @@ const userController = {
if (!recover_code) { return res.sendStatus(400) }
const user = await User.findOne({ where: { recover_code: { [Op.eq]: recover_code } } })
if (!user) { return res.sendStatus(400) }
try {
await user.update({ recover_code: '' })
res.sendStatus(200)
} catch (e) {
res.sendStatus(400)
}
},
async updatePasswordWithRecoverCode (req, res) {
......@@ -198,10 +193,8 @@ const userController = {
if (!recover_code || !password) { return res.sendStatus(400) }
const user = await User.findOne({ where: { recover_code: { [Op.eq]: recover_code } } })
if (!user) { return res.sendStatus(400) }
user.recover_code = ''
user.password = password
try {
await user.save()
await user.update({ recover_code: '', password })
res.sendStatus(200)
} catch (e) {
res.sendStatus(400)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment