A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: add support for changing account email
Abdullah Attab439571e171e
diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex 1518e3123..cc0b5a9a8 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -256,8 +256,12 @@ class Database {await this.user.logout(false, "Account Deleted");break;}+ case "userEmailChanged": {+ await this.user.logout(true, "Email changed");+ break;+ }case "userPasswordChanged": {- await this.user.logout(true, "Password Changed");+ await this.user.logout(true, "Password changed");break;}case "emailConfirmed": {diff --git a/packages/core/api/user-manager.js b/packages/core/api/user-manager.jsindex 0d9bc2171..335beb630 100644--- a/packages/core/api/user-manager.js+++ b/packages/core/api/user-manager.js@@ -322,14 +322,40 @@ class UserManager {}}- async sendVerificationEmail() {+ async sendVerificationEmail(newEmail) {let token = await this.tokenManager.getAccessToken();if (!token) return;await http.post(`${constants.AUTH_HOST}${ENDPOINTS.verifyUser}`,- null,+ { newEmail },+ token+ );+ }++ async changeEmail(newEmail, password, code) {+ const token = await this.tokenManager.getAccessToken();+ if (!token) return;++ const user = await this.getUser();+ if (!user) return;++ const email = newEmail.toLowerCase();++ await http.patch(+ `${constants.AUTH_HOST}${ENDPOINTS.patchUser}`,+ {+ type: "change_email",+ new_email: newEmail,+ password: await this._storage.hash(password, email),+ verification_code: code+ },token);++ await this._storage.deriveCryptoKey(`_uk_@${newEmail}`, {+ password,+ salt: user.salt+ });}recoverAccount(email) {