From 8cf3f74aff9a3db3725cd85b12946e6b9b18082d Mon Sep 17 00:00:00 2001 From: Alexey Safronov Date: Tue, 27 Dec 2022 13:45:47 +0300 Subject: [PATCH] Fix Bug 60353 - Accounts: Sign Up. Portal registration fails. (@self.json 401) --- packages/common/store/AuthStore.js | 15 ++++++++------- packages/common/store/UserStore.js | 6 +++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/common/store/AuthStore.js b/packages/common/store/AuthStore.js index 27ddea25f9..dd14581dc0 100644 --- a/packages/common/store/AuthStore.js +++ b/packages/common/store/AuthStore.js @@ -53,14 +53,15 @@ class AuthStore { this.skipRequest = skipRequest; - try { - await this.userStore.init(); - } catch (e) { - console.error(e); - } + await this.settingsStore.init(); const requests = []; - requests.push(this.settingsStore.init()); + + if (this.settingsStore.isLoaded && this.settingsStore.socketUrl) { + requests.push(this.userStore.init()); + } else { + this.userStore.setIsLoaded(true); + } if (this.isAuthenticated && !skipRequest) { requests.push( @@ -222,7 +223,7 @@ class AuthStore { get isAuthenticated() { return ( - this.userStore.isAuthenticated || + (this.settingsStore.isLoaded && this.settingsStore.socketUrl) || //this.userStore.isAuthenticated || this.settingsStore.tenantStatus === TenantStatus.PortalRestore ); } diff --git a/packages/common/store/UserStore.js b/packages/common/store/UserStore.js index 7648bac332..3c439bb23b 100644 --- a/packages/common/store/UserStore.js +++ b/packages/common/store/UserStore.js @@ -31,7 +31,11 @@ class UserStore { this.setIsLoading(true); - await this.loadCurrentUser(); + try { + await this.loadCurrentUser(); + } catch (e) { + console.error(e); + } this.setIsLoading(false); this.setIsLoaded(true);