fix: don't re-encode public key when changing e2e password (#5174)

Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
This commit is contained in:
Aviad Pineles 2023-09-12 16:06:29 +03:00 committed by GitHub
parent 6a610a956f
commit 9f8799d729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -199,10 +199,16 @@ class Encryption {
// Encode the private key
const encodedPrivateKey = await this.encodePrivateKey(EJSON.stringify(privateKey), password, this.userId as string);
// This public key is already encoded using EJSON.stringify in the `persistKeys` method
const publicKey = UserPreferences.getString(`${server}-${E2E_PUBLIC_KEY}`);
if (!publicKey) {
throw new Error('Public key not found in local storage, password not changed');
}
// Send the new keys to the server
await Services.e2eSetUserPublicAndPrivateKeys(EJSON.stringify(publicKey), encodedPrivateKey);
await Services.e2eSetUserPublicAndPrivateKeys(publicKey, encodedPrivateKey);
};
// get a encryption room instance