angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.13k stars 1.24k forks source link

Reset Password Not working in fullstack@3.8.0 #2657

Closed akshayseth closed 6 years ago

akshayseth commented 6 years ago

Hi, I am using angular fullstack v3.8.0 for my web application.I am trying to give a functionality in which if he hits forget password an OTP will be sent to is email and number.And if that OTP is valid he will see a screen of type password and retype password. I have seen the API for change password and I have just removed the line(if statement): if (user.authenticate(oldPass)) {}

Below is my code which I have used to reset the password: User.find({"email":req.query.mail},function(er,user){ if(er){ return res.status(403).end(); } else{ console.log("and the user is"); console.log(user); return User.findById(user[0]._id).exec() .then(user => { user.password = passwrd; return user.save() .then(() => { res.status(204).end(); }) .catch(validationError(res));

    });
}

})

But I am getting error which is below: (node:1023) DeprecationWarning: Implicit async custom validators (custom validators that take 2 arguments) are deprecated in mongoose >= 4.9.0. See http://mongoosejs.com/docs/validation.html#async-custom-validators for more info. crypto.js:635 throw new TypeError( ^

TypeError: The "digest" argument is required and must not be undefined at pbkdf2 (crypto.js:635:11) at Object.exports.pbkdf2 (crypto.js:623:10)

Awk34 commented 6 years ago

This has been fixed in newer versions of the generator. On newer versions of Node.js, the 'digest' argument is required for pbkdf2: https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback

akshayseth commented 6 years ago

Migrating to newer version of the generator is not at all possible... :( So should I downgrade my node or something like that?

akshayseth commented 6 years ago

Well I downgraded my node version to 6.10.3 and now it is working fine.Thanks for your inputs man @Awk34

Awk34 commented 6 years ago

Sorry, I pasted the wrong link. I've fixed the link to the Node.js docs for the pbkdf2 function

akshayseth commented 6 years ago

Much Thanks mate !