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: refresh token on user subscription change
Abdullah Atta1274ecc3b503
diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.tsindex 964c2cbe2..c33e42e99 100644--- a/packages/core/src/api/index.ts+++ b/packages/core/src/api/index.ts@@ -388,6 +388,7 @@ class Database {user.subscription = data;await this.user.setUser(user);EV.publish(EVENTS.userSubscriptionUpdated, data);+ await this.tokenManager._refreshToken(true);break;}case "logout": {diff --git a/packages/core/src/api/user-manager.ts b/packages/core/src/api/user-manager.tsindex eef5bd414..cb826f228 100644--- a/packages/core/src/api/user-manager.ts+++ b/packages/core/src/api/user-manager.ts@@ -315,6 +315,17 @@ class UserManager {token);if (user) {+ const oldUser = await this.getUser();+ if (+ oldUser &&+ (oldUser.subscription.type !== user.subscription.type ||+ oldUser.subscription.provider !== user.subscription.provider)+ ) {+ await this.tokenManager._refreshToken(true);+ EV.publish(EVENTS.userSubscriptionUpdated, user.subscription);+ }+ if (oldUser && !oldUser.isEmailConfirmed && user.isEmailConfirmed)+ EV.publish(EVENTS.userEmailConfirmed);await this.setUser(user);EV.publish(EVENTS.userFetched, user);return user;