summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-20 09:58:16 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-20 09:58:16 -0300
commit510fe266c62d401c1a36d3b18388bf84d32bd50c (patch)
tree4906e7155ccf328145c5741567d9f4b14c455749
parentf8589dea63e0769621ad62aff4f693d0e0e9fe88 (diff)
parent4becdfcfd07641012b2f786217d99371d82c7ff2 (diff)
downloadmullvadvpn-510fe266c62d401c1a36d3b18388bf84d32bd50c.tar.xz
mullvadvpn-510fe266c62d401c1a36d3b18388bf84d32bd50c.zip
Merge branch 'login-when-master-api-is-unavailable'
-rw-r--r--CHANGELOG.md3
-rw-r--r--gui/packages/desktop/src/renderer/app.js30
2 files changed, 31 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 630d900f1e..434f8d1da6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,9 @@ Line wrap the file at 100 chars. Th
#### Linux
- Add support for DNS configuration using resolvconf.
+### Changed
+- Logging in no longer requires a connection with the Mullvad API server.
+
### Fixed
- Don't temporarily show the unsecured state in the GUI when the app is reconnecting or blocking.
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js
index 5c432c9e75..a99fbc3fed 100644
--- a/gui/packages/desktop/src/renderer/app.js
+++ b/gui/packages/desktop/src/renderer/app.js
@@ -12,6 +12,7 @@ import {
} from 'connected-react-router';
import { createMemoryHistory } from 'history';
+import { InvalidAccountError } from './errors';
import makeRoutes from './routes';
import ReconnectionBackoff from './lib/reconnection-backoff';
import { DaemonRpc, ConnectionObserver } from './lib/daemon-rpc';
@@ -134,10 +135,16 @@ export default class AppRenderer {
log.debug('Logging in');
try {
- const accountData = await this._daemonRpc.getAccountData(accountToken);
+ const verification = await this.verifyAccount(accountToken);
+
await this._daemonRpc.setAccount(accountToken);
- actions.account.updateAccountExpiry(accountData.expiry);
+ if (verification.status === 'verified') {
+ actions.account.updateAccountExpiry(verification.accountData.expiry);
+ } else if (verification.status === 'deferred') {
+ log.debug(`Failed to get account data, logging in anyway: ${verification.error.message}`);
+ }
+
actions.account.loginSuccessful();
// Redirect the user after some time to allow for
@@ -161,6 +168,21 @@ export default class AppRenderer {
}
}
+ async verifyAccount(accountToken: AccountToken): Promise<AccountVerification> {
+ try {
+ return {
+ status: 'verified',
+ accountData: await this._daemonRpc.getAccountData(accountToken),
+ };
+ } catch (error) {
+ if (error instanceof InvalidAccountError) {
+ throw error;
+ } else {
+ return { status: 'deferred', error };
+ }
+ }
+ }
+
async logout() {
const actions = this._reduxActions;
@@ -576,6 +598,10 @@ export default class AppRenderer {
}
}
+type AccountVerification =
+ | { status: 'verified', accountData: AccountData }
+ | { status: 'deferred', error: Error };
+
// An account data cache that helps to throttle RPC requests to get_account_data and retain the
// cached value for 1 minute.
class AccountDataCache {