fix: handle demo signin less generically (#497)

This commit is contained in:
Baptiste Grob
2020-11-12 11:40:07 +01:00
committed by GitHub
parent 0b409062da
commit 50a5cc4851

View File

@@ -76,7 +76,7 @@ class ApplicationViewCtrl extends PureViewCtrl {
async onAppLaunch() { async onAppLaunch() {
super.onAppLaunch(); super.onAppLaunch();
this.setState({ needsUnlock: false }); this.setState({ needsUnlock: false });
this.handleAutoSignInFromParams(); this.handleDemoSignInFromParams();
} }
onUpdateAvailable() { onUpdateAvailable() {
@@ -142,28 +142,19 @@ class ApplicationViewCtrl extends PureViewCtrl {
} }
} }
async handleAutoSignInFromParams() { async handleDemoSignInFromParams() {
const params = this.$location!.search(); if (
const server = params.server; this.$location!.search().demo === 'true' &&
const email = params.email; !this.application.hasAccount()
const password = params.pw; ) {
if (!server || !email || !password) return; await this.application!.setHost(
'https://syncing-server-demo.standardnotes.org'
const user = this.application!.getUser(); );
if (user) { this.application!.signIn(
if (user.email === email && await this.application!.getHost() === server) { 'demo@standardnotes.org',
/** Already signed in, return */ 'password',
return; );
} else {
/** Sign out */
await this.application!.signOut();
}
} }
await this.application!.setHost(server);
this.application!.signIn(
email,
password,
);
} }
} }