summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-03-09 10:15:32 +0100
committerOskar Nyberg <oskar@mullvad.net>2022-03-14 13:58:44 +0100
commit55aa3418f8b7ec6f473fd22819f7e54cb432d097 (patch)
tree302357507a7e51ece04f563c5f7018d64adaccac /gui/src
parent8659f97d48369e3d61aee615bea06ffe30164f83 (diff)
downloadmullvadvpn-55aa3418f8b7ec6f473fd22819f7e54cb432d097.tar.xz
mullvadvpn-55aa3418f8b7ec6f473fd22819f7e54cb432d097.zip
Fix login redirect
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/app.tsx19
1 files changed, 12 insertions, 7 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index ea6c12cc84..778bf4cdbd 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -57,6 +57,8 @@ interface IPreferredLocaleDescriptor {
code: string;
}
+type LoginState = 'none' | 'logging in' | 'creating account' | 'too many devices';
+
const SUPPORTED_LOCALE_LIST = [
{ name: 'Dansk', code: 'da' },
{ name: 'Deutsch', code: 'de' },
@@ -98,7 +100,8 @@ export default class AppRenderer {
private settings!: ISettings;
private deviceConfig?: IDeviceConfig;
private guiSettings!: IGuiSettingsState;
- private loginState: 'none' | 'logging in' | 'creating account' | 'too many devices' = 'none';
+ private loginState: LoginState = 'none';
+ private previousLoginState: LoginState = 'none';
private loginScheduler = new Scheduler();
private connectedToDaemon = false;
private getLocationPromise?: Promise<ILocation>;
@@ -266,16 +269,11 @@ export default class AppRenderer {
log.info('Logging in');
- const previousLoginState = this.loginState;
+ this.previousLoginState = this.loginState;
this.loginState = 'logging in';
try {
await IpcRendererEventChannel.account.login(accountToken);
- if (previousLoginState === 'too many devices') {
- this.resetNavigation();
- } else {
- this.redirectToConnect();
- }
} catch (e) {
const error = e as Error;
if (error.message === 'Too many devices') {
@@ -812,6 +810,12 @@ export default class AppRenderer {
case 'none':
case 'logging in':
reduxAccount.loggedIn({ accountToken: newAccount, device: newDevice });
+
+ if (this.previousLoginState === 'too many devices') {
+ this.resetNavigation();
+ } else {
+ this.redirectToConnect();
+ }
break;
case 'creating account':
reduxAccount.accountCreated(
@@ -826,6 +830,7 @@ export default class AppRenderer {
}
}
+ this.previousLoginState = this.loginState;
this.loginState = 'none';
}