summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-07-28 11:38:41 +0200
committerErik Larkö <erik@mullvad.net>2017-07-28 11:38:41 +0200
commite13fe630fce123981e502939aafc3569a9412e0c (patch)
treec45c1e6ae79c1702c7285820e8823a9b94b2ebca /app/lib
parenta196629083e1fb634a1d65e816a1b4bdfbdeb072 (diff)
parent5616dddc92d76a121d10cbbab5b6404c71ffc25b (diff)
downloadmullvadvpn-e13fe630fce123981e502939aafc3569a9412e0c.tar.xz
mullvadvpn-e13fe630fce123981e502939aafc3569a9412e0c.zip
Merge branch 'login-actions'
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js21
1 files changed, 5 insertions, 16 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 3c322afa6d..a58a12a0cd 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -148,16 +148,12 @@ export class Backend {
}
- login(accountNumber: string) {
+ login(accountNumber: string): Promise<void> {
log.info('Attempting to login with account number', accountNumber);
- this._store.dispatch(accountActions.loginChange({
- accountNumber: accountNumber,
- status: 'logging in',
- error: null,
- }));
+ this._store.dispatch(accountActions.startLogin(accountNumber));
- this._ipc.getAccountData(accountNumber)
+ return this._ipc.getAccountData(accountNumber)
.then( response => {
log.info('Account exists', response);
@@ -167,11 +163,7 @@ export class Backend {
}).then( accountData => {
log.info('Log in complete');
- this._store.dispatch(accountActions.loginChange({
- status: 'ok',
- paidUntil: accountData.paid_until,
- error: null,
- }));
+ this._store.dispatch(accountActions.loginSuccessful(accountData.paid_until));
// Redirect the user after some time to allow for
// the 'Login Successful' screen to be visible
@@ -183,10 +175,7 @@ export class Backend {
// TODO: This is not true. If there is a communication link failure the promise will be rejected too
const err = new BackendError('INVALID_ACCOUNT');
- this._store.dispatch(accountActions.loginChange({
- status: 'failed',
- error: err,
- }));
+ this._store.dispatch(accountActions.loginFailed(err));
});
}