summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-03-12 13:37:46 +0100
committerOskar Nyberg <oskar@mullvad.net>2021-03-14 09:42:22 +0100
commita43ff8d7b66e1b476b0714dbf27b7b9b8e40da85 (patch)
treed209c1394591935284ae36de6404c0e19d68ed68 /gui/src
parent5cf2e320362a65ac8790f578bd1765c6e47d4eb7 (diff)
downloadmullvadvpn-a43ff8d7b66e1b476b0714dbf27b7b9b8e40da85.tar.xz
mullvadvpn-a43ff8d7b66e1b476b0714dbf27b7b9b8e40da85.zip
Require daemon-connection when navigating to connect or login
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/app.tsx35
1 files changed, 22 insertions, 13 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 9f7c6b5d2b..495cd2dc7c 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -96,6 +96,7 @@ export default class AppRenderer {
private autoConnected = false;
private doingLogin = false;
private loginTimer?: NodeJS.Timeout;
+ private connectedToDaemon = false;
constructor() {
log.addOutput(new ConsoleOutput(LogLevel.debug));
@@ -493,7 +494,11 @@ export default class AppRenderer {
private redirectToConnect() {
// Redirect the user after some time to allow for the 'Logged in' screen to be visible
- this.loginTimer = global.setTimeout(() => this.history.resetWith('/connect'), 1000);
+ this.loginTimer = global.setTimeout(() => {
+ if (this.connectedToDaemon) {
+ this.history.resetWith('/connect');
+ }
+ }, 1000);
}
private setLocale(locale: string) {
@@ -558,6 +563,7 @@ export default class AppRenderer {
}
private async onDaemonConnected() {
+ this.connectedToDaemon = true;
if (this.settings.accountToken) {
this.history.resetWith('/connect');
@@ -569,6 +575,7 @@ export default class AppRenderer {
}
private onDaemonDisconnected() {
+ this.connectedToDaemon = false;
this.history.resetWith('/');
}
@@ -674,19 +681,21 @@ export default class AppRenderer {
}
private handleAccountChange(oldAccount?: string, newAccount?: string) {
- const reduxAccount = this.reduxActions.account;
+ if (this.connectedToDaemon) {
+ const reduxAccount = this.reduxActions.account;
- if (oldAccount && !newAccount) {
- if (this.loginTimer) {
- clearTimeout(this.loginTimer);
- }
- reduxAccount.loggedOut();
- this.history.resetWith('/login');
- } else if (newAccount && oldAccount !== newAccount && !this.doingLogin) {
- reduxAccount.updateAccountToken(newAccount);
- reduxAccount.loggedIn();
- if (!oldAccount) {
- this.history.resetWith('/connect');
+ if (oldAccount && !newAccount) {
+ if (this.loginTimer) {
+ clearTimeout(this.loginTimer);
+ }
+ reduxAccount.loggedOut();
+ this.history.resetWith('/login');
+ } else if (newAccount && oldAccount !== newAccount && !this.doingLogin) {
+ reduxAccount.updateAccountToken(newAccount);
+ reduxAccount.loggedIn();
+ if (!oldAccount) {
+ this.history.resetWith('/connect');
+ }
}
}