summaryrefslogtreecommitdiffhomepage
path: root/app/lib/backend.js
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-08-07 13:30:10 +0200
committerErik Larkö <erik@mullvad.net>2017-08-07 13:30:10 +0200
commitdbd9843c12eef4828468fd9ea4500280ea5caa69 (patch)
treee2d93e9c150681522459e619bc2d7cff5e433695 /app/lib/backend.js
parent0fd8de3cdfdf8957ad3362643fcd8e8ef9888794 (diff)
parent0990f4cfbe4df6675637b97df429d2155000d7ff (diff)
downloadmullvadvpn-dbd9843c12eef4828468fd9ea4500280ea5caa69.tar.xz
mullvadvpn-dbd9843c12eef4828468fd9ea4500280ea5caa69.zip
Merge branch 'autologin-actions'
Diffstat (limited to 'app/lib/backend.js')
-rw-r--r--app/lib/backend.js25
1 files changed, 4 insertions, 21 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index a58a12a0cd..d36fc36d41 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -182,11 +182,7 @@ export class Backend {
autologin() {
log.info('Attempting to log in automatically');
- this._store.dispatch(accountActions.loginChange({
- accountNumber: null,
- status: 'logging in',
- error: null,
- }));
+ this._store.dispatch(accountActions.startLogin());
return this._ipc.getAccount()
.then( accountNumber => {
@@ -194,34 +190,21 @@ export class Backend {
throw new Error('No account set in the backend, failing autologin');
}
log.debug('The backend had an account number stored:', accountNumber);
-
- this._store.dispatch(accountActions.loginChange({
- accountNumber: accountNumber,
- status: 'logging in',
- error: null,
- }));
+ this._store.dispatch(accountActions.startLogin(accountNumber));
return this._ipc.getAccountData(accountNumber);
})
.then( accountData => {
log.info('The stored account number still exists', accountData);
- this._store.dispatch(accountActions.loginChange({
- status: 'ok',
- paidUntil: accountData.paid_until,
- error: null,
- }));
+ this._store.dispatch(accountActions.loginSuccessful(accountData.paid_until));
this._store.dispatch(push('/connect'));
})
.catch( e => {
log.warn('Unable to autologin', e);
- this._store.dispatch(accountActions.loginChange({
- status: 'none',
- error: new BackendError('INVALID_ACCOUNT'),
- }));
-
+ this._store.dispatch(accountActions.loginFailed(new BackendError('INVALID_ACCOUNT')));
this._store.dispatch(push('/'));
});
}