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
feat: add resetPassword
thecodrr1b1bc9668320
diff --git a/packages/core/api/outbox.js b/packages/core/api/outbox.jsindex d55b56eab..5db4092f0 100644--- a/packages/core/api/outbox.js+++ b/packages/core/api/outbox.js@@ -15,6 +15,7 @@ class Outbox {const data = this.outbox[id];switch (id) {case "reset_password":+ case "change_password":const key = await this._db.user.getEncryptionKey();const { email } = await this._db.user.getUser();await this._db.context.deriveCryptoKey(`_uk_@${email}`, {diff --git a/packages/core/api/user-manager.js b/packages/core/api/user-manager.jsindex 01a32877a..6d587ddc9 100644--- a/packages/core/api/user-manager.js+++ b/packages/core/api/user-manager.js@@ -112,6 +112,19 @@ class UserManager {}}+ changePassword(oldPassword, newPassword) {+ return this._updatePassword("change_password", {+ old_password: oldPassword,+ new_password: newPassword,+ });+ }++ resetPassword(newPassword) {+ return this._updatePassword("reset_password", {+ new_password: newPassword,+ });+ }+async getEncryptionKey() {const user = await this.getUser();if (!user) return;@@ -119,19 +132,35 @@ class UserManager {return { key, salt: user.salt };}- async resetPassword(oldPassword, newPassword) {+ async sendVerificationEmail() {+ let token = await this.tokenManager.getAccessToken();+ if (!token) return;+ await http.post(+ `${constants.AUTH_HOST}${ENDPOINTS.verifyUser}`,+ null,+ token+ );+ }++ recoverAccount(email) {+ return http.post(`${constants.AUTH_HOST}${ENDPOINTS.recoverAccount}`, {+ email,+ client_id: "notesnook",+ });+ }++ async _updatePassword(type, data) {let token = await this.tokenManager.getAccessToken();if (!token) return;await http.patch(`${constants.AUTH_HOST}/${ENDPOINTS.patchUser}`,{- type: "reset_password",- old_password: oldPassword,- new_password: newPassword,+ type,+ ...data,},token);- await this._db.outbox.add("reset_password", { newPassword }, async () => {+ await this._db.outbox.add(type, { newPassword }, async () => {const key = await this.getEncryptionKey();const { email } = await this.getUser();await this._db.context.deriveCryptoKey(`_uk_@${email}`, {@@ -142,23 +171,6 @@ class UserManager {});return true;}-- async sendVerificationEmail() {- let token = await this.tokenManager.getAccessToken();- if (!token) return;- await http.post(- `${constants.AUTH_HOST}${ENDPOINTS.verifyUser}`,- null,- token- );- }-- recoverAccount(email) {- return http.post(`${constants.AUTH_HOST}${ENDPOINTS.recoverAccount}`, {- email,- client_id: "notesnook",- });- }}export default UserManager;