Nikolasel/EAuthenticator

How To Reset Password If Forgot Password

phpgraduate opened this issue · 3 comments

Hi, I'm trying to add forgot password function in this repo to set a new password.
/**
* Forgot password
* @param newPassword
* @throws error, if newPassword is incorrect
*/
forgotPassword(newPassword) {
if (newPassword != "") {
let enc = new TextEncoder("utf-8");
this.chaChaPassword = new ChaCha20(this.keyPassword, this.keyPasswordNonce).encrypt(enc.encode(newPassword));
this.useDefaultPassword = false;
}
else throw new Error("Incorrect old password");
}

I tried this but it is not working can anyone help me with this.

Basically the secrets are differently encrypted depending on the Storage. On hard drives they are encrypted using OpenPGP symmetric encryption and in Memory via ChaCha20.
If you only have a the file that is placed on the hard Drive, the only possibility to recover it is via cracking. Depending on the password strength this can take years.

Does it mean if I forgot the password I can never access my account?

Correct, otherwise encryption makes no sense, everyone is then able to reset the password.