From 50a5cc48513aa615943db56fec961546fe2a1e18 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Thu, 12 Nov 2020 11:40:07 +0100 Subject: [PATCH] fix: handle demo signin less generically (#497) --- .../views/application/application_view.ts | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/views/application/application_view.ts b/app/assets/javascripts/views/application/application_view.ts index 28229819f..ebb346437 100644 --- a/app/assets/javascripts/views/application/application_view.ts +++ b/app/assets/javascripts/views/application/application_view.ts @@ -76,7 +76,7 @@ class ApplicationViewCtrl extends PureViewCtrl { async onAppLaunch() { super.onAppLaunch(); this.setState({ needsUnlock: false }); - this.handleAutoSignInFromParams(); + this.handleDemoSignInFromParams(); } onUpdateAvailable() { @@ -142,28 +142,19 @@ class ApplicationViewCtrl extends PureViewCtrl { } } - async handleAutoSignInFromParams() { - const params = this.$location!.search(); - const server = params.server; - const email = params.email; - const password = params.pw; - if (!server || !email || !password) return; - - const user = this.application!.getUser(); - if (user) { - if (user.email === email && await this.application!.getHost() === server) { - /** Already signed in, return */ - return; - } else { - /** Sign out */ - await this.application!.signOut(); - } + async handleDemoSignInFromParams() { + if ( + this.$location!.search().demo === 'true' && + !this.application.hasAccount() + ) { + await this.application!.setHost( + 'https://syncing-server-demo.standardnotes.org' + ); + this.application!.signIn( + 'demo@standardnotes.org', + 'password', + ); } - await this.application!.setHost(server); - this.application!.signIn( - email, - password, - ); } }