summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--gui/src/main/index.ts15
-rw-r--r--gui/src/renderer/app.tsx19
3 files changed, 22 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8be0c1bcdb..d8eda8525b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,8 +39,10 @@ Line wrap the file at 100 chars. Th
### Fixed
-- Show both WireGuard and OpenVPN servers in location list when protocol is set to automatic on Linux and macOS.
+- Show both WireGuard and OpenVPN servers in location list when protocol is set to automatic on
+ Linux and macOS.
- Fix missing in app notification about unsupported version.
+- Prevent auto-connect on login if the account is out of time.
#### Android
- Fix crash when that happened sometimes when the app tried to start the daemon service on recent
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index d64ff7cf93..ba9f8a9baa 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -1108,6 +1108,7 @@ class ApplicationMain {
}
await this.daemonRpc.setAccount(accountToken);
+ consumePromise(this.autoConnect());
} catch (error) {
log.error(`Failed to login: ${error.message}`);
@@ -1119,6 +1120,20 @@ class ApplicationMain {
}
}
+ private async autoConnect() {
+ if (
+ !this.accountData ||
+ !new AccountExpiry(this.accountData.expiry, this.locale).hasExpired()
+ ) {
+ try {
+ log.info('Auto-connecting the tunnel');
+ await this.daemonRpc.connectTunnel();
+ } catch (error) {
+ log.error(`Failed to auto-connect the tunnel: ${error.message}`);
+ }
+ }
+ }
+
private async logout(): Promise<void> {
try {
await this.daemonRpc.setAccount();
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 5c1623b67e..b5afb608ec 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -242,7 +242,7 @@ export default class AppRenderer {
await IpcRendererEventChannel.account.login(accountToken);
actions.account.updateAccountToken(accountToken);
actions.account.loggedIn();
- this.redirectToConnect(true);
+ this.redirectToConnect();
} catch (error) {
actions.account.loginFailed(error);
}
@@ -267,7 +267,7 @@ export default class AppRenderer {
const accountToken = await IpcRendererEventChannel.account.create();
const accountExpiry = new Date().toISOString();
actions.account.accountCreated(accountToken, accountExpiry);
- this.redirectToConnect(false);
+ this.redirectToConnect();
} catch (error) {
actions.account.createAccountFailed(error);
}
@@ -431,20 +431,9 @@ export default class AppRenderer {
return preferredLocale ? preferredLocale.name : '';
}
- private redirectToConnect(connect: boolean) {
+ private redirectToConnect() {
// Redirect the user after some time to allow for the 'Logged in' screen to be visible
- this.loginTimer = global.setTimeout(async () => {
- this.memoryHistory.replace('/connect');
-
- if (connect) {
- try {
- log.info('Auto-connecting the tunnel');
- await this.connectTunnel();
- } catch (error) {
- log.error(`Failed to auto-connect the tunnel: ${error.message}`);
- }
- }
- }, 1000);
+ this.loginTimer = global.setTimeout(() => this.memoryHistory.replace('/connect'), 1000);
}
private loadTranslations(locale: string) {