aloux-iam 0.0.62 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/services/auth.js +7 -2
- package/package.json +1 -1
package/lib/services/auth.js
CHANGED
|
@@ -626,16 +626,21 @@ self.validateCode = async (req, res) => {
|
|
|
626
626
|
if (req.user.validateKey.limitCodeTime < newTime) {
|
|
627
627
|
throw { code: 409, title: 'El código ha caducado.', detail: '', suggestion: 'Vuelve a intentarlo', error: new Error() }
|
|
628
628
|
}
|
|
629
|
+
const userFind = await User.findOne({email: req.body.email},{_id: 1}).lean()
|
|
630
|
+
|
|
631
|
+
if(userFind){
|
|
632
|
+
throw { code: 409, title: 'Ya existe un usuario con ese correo', detail: '', suggestion: 'Prueba con otro correo', error: new Error() }
|
|
633
|
+
}
|
|
629
634
|
|
|
630
635
|
if(req.body.code === req.user.validateKey.resetPassword.resetCode){
|
|
631
636
|
await User.updateOne(
|
|
632
637
|
{
|
|
633
638
|
_id: req.user._id,
|
|
634
|
-
email: req.body.email
|
|
635
639
|
},
|
|
636
640
|
{
|
|
637
641
|
"validateKey.resetPassword.validCode": true,
|
|
638
|
-
"validateKey.validateEmail.emailVerified": true
|
|
642
|
+
"validateKey.validateEmail.emailVerified": true,
|
|
643
|
+
email: req.body.email
|
|
639
644
|
})
|
|
640
645
|
return true
|
|
641
646
|
}else{
|