summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-11-16 09:32:24 +0100
committerErik Larkö <erik@mullvad.net>2017-11-20 10:54:17 +0100
commitfc28970c6382755d536bf485d81929281e5653bf (patch)
tree9c87bf1d3c3be4e377bd9dbb75416abc779094b0 /app
parent258eb7a91ef65d3f1692718c5d8a14b2eab12b78 (diff)
downloadmullvadvpn-fc28970c6382755d536bf485d81929281e5653bf.tar.xz
mullvadvpn-fc28970c6382755d536bf485d81929281e5653bf.zip
Always connect to the server set in the settings
Diffstat (limited to 'app')
-rw-r--r--app/app.js4
-rw-r--r--app/lib/backend.js15
2 files changed, 13 insertions, 6 deletions
diff --git a/app/app.js b/app/app.js
index 6536de4983..5cdf7e78d9 100644
--- a/app/app.js
+++ b/app/app.js
@@ -30,6 +30,10 @@ ipcRenderer.on('backend-info', (_event, args) => {
.then( () => {
return backend.syncRelayConstraints();
})
+ .then( () => {
+ const { settings } = store.getState();
+ return backend.connect(settings.relayConstraints.host);
+ })
.catch( e => {
if (e.type === 'NO_ACCOUNT') {
log.debug('No user set in the backend, showing window');
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 496ad9b3b6..fe828ba6c8 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -186,12 +186,18 @@ export class Backend {
log.info('Log in complete');
this._store.dispatch(accountActions.loginSuccessful(accountData.expiry));
+ return this.syncRelayConstraints();
+ })
+ .then( () => {
// Redirect the user after some time to allow for
// the 'Login Successful' screen to be visible
setTimeout(() => {
+ const { host } = this._store.getState().settings.relayConstraints;
+ log.debug('Autoconnecting to', host);
+
this._store.dispatch(push('/connect'));
- this.connect();
+ this.connect(host);
}, 1000);
}).catch(e => {
log.error('Failed to log in,', e.message);
@@ -224,9 +230,7 @@ export class Backend {
log.debug('The stored account number still exists', accountData);
this._store.dispatch(accountActions.loginSuccessful(accountData.expiry));
-
- this._store.dispatch(push('/connect'));
- this.connect();
+ return this._store.dispatch(push('/connect'));
})
.catch( e => {
log.warn('Unable to autologin,', e.message);
@@ -260,8 +264,7 @@ export class Backend {
});
}
- connect(aHost?: string): Promise<void> {
- const host = aHost;
+ connect(host: string): Promise<void> {
let setHostPromise = () => Promise.resolve();
if (host) {