Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: reset user on account recovery

thecodrr692b50cf84c8
diff --git a/packages/core/api/user-manager.js b/packages/core/api/user-manager.js
index 2fb505cbc..506c62242 100644
--- a/packages/core/api/user-manager.js
+++ b/packages/core/api/user-manager.js
@@ -13,6 +13,7 @@ const ENDPOINTS = {
verifyUser: "/account/verify",
revoke: "/connect/revocation",
recoverAccount: "/account/recover",
+ resetUser: "/users/reset",
activateTrial: "/subscriptions/trial",
};
@@ -148,6 +149,17 @@ class UserManager {
return this._storage.read("user");
}
+ async resetUser(removeAttachments = true) {
+ let token = await this.tokenManager.getAccessToken();
+ if (!token) return;
+ await http.post(
+ `${constants.API_HOST}${ENDPOINTS.resetUser}`,
+ { removeAttachments },
+ token
+ );
+ return true;
+ }
+
async updateUser(user) {
if (!user) return;
@@ -309,6 +321,8 @@ class UserManager {
salt,
});
+ if (!(await this.resetUser(false))) return;
+
if (attachmentsKey) {
const userEncryptionKey = await this.getEncryptionKey();
if (!userEncryptionKey) return;