summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-07-27 10:58:01 +0200
committerErik Larkö <erik@mullvad.net>2017-07-28 11:25:16 +0200
commit98204a12250222cf5adfb51e9db42d8b28794335 (patch)
treee028a7a3565391790a8ba3e47201607fef0b1201
parente2bf350e0742724f86a131c7421fea50c839f378 (diff)
downloadmullvadvpn-98204a12250222cf5adfb51e9db42d8b28794335.tar.xz
mullvadvpn-98204a12250222cf5adfb51e9db42d8b28794335.zip
Add LOGIN_SUCCESSFUL action
-rw-r--r--app/lib/backend.js7
-rw-r--r--app/redux/account/actions.js15
-rw-r--r--app/redux/account/reducers.js6
3 files changed, 20 insertions, 8 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 53e724fcfc..8ad3c2fe32 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -163,12 +163,7 @@ export class Backend {
}).then( accountData => {
log.info('Log in complete');
- this._store.dispatch(accountActions.loginChange({
- status: 'ok',
- accountNumber: accountNumber,
- 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
diff --git a/app/redux/account/actions.js b/app/redux/account/actions.js
index 5e423f3aa8..d1e240f39e 100644
--- a/app/redux/account/actions.js
+++ b/app/redux/account/actions.js
@@ -7,13 +7,17 @@ type StartLoginAction = {
type: 'START_LOGIN',
accountNumber: string,
};
+type LoginSuccessfulAction = {
+ type: 'LOGIN_SUCCESSFUL',
+ paidUntil: string,
+};
type LoginChangeAction = {
type:'LOGIN_CHANGE',
newData: $Shape<AccountReduxState>,
};
-export type AccountAction = StartLoginAction | LoginChangeAction;
+export type AccountAction = StartLoginAction | LoginSuccessfulAction | LoginChangeAction;
function startLogin(accountNumber: string): StartLoginAction {
return {
@@ -22,6 +26,13 @@ function startLogin(accountNumber: string): StartLoginAction {
};
}
+function loginSuccessful(paidUntil: string): LoginSuccessfulAction {
+ return {
+ type: 'LOGIN_SUCCESSFUL',
+ paidUntil: paidUntil,
+ };
+}
+
function loginChange(data: $Shape<AccountReduxState>): LoginChangeAction {
return {
type: 'LOGIN_CHANGE',
@@ -32,4 +43,4 @@ function loginChange(data: $Shape<AccountReduxState>): LoginChangeAction {
const login = (backend: Backend, account: string) => () => backend.login(account);
const logout = (backend: Backend) => () => backend.logout();
-export default { login, logout, loginChange, startLogin };
+export default { login, logout, loginChange, startLogin, loginSuccessful };
diff --git a/app/redux/account/reducers.js b/app/redux/account/reducers.js
index 2ac8595d90..975c15e772 100644
--- a/app/redux/account/reducers.js
+++ b/app/redux/account/reducers.js
@@ -29,6 +29,12 @@ export default function(state: AccountReduxState = initialState, action: ReduxAc
accountNumber: action.accountNumber,
error: null,
}};
+ case 'LOGIN_SUCCESSFUL':
+ return { ...state, ...{
+ status: 'ok',
+ error: null,
+ paidUntil: action.paidUntil,
+ }};
}
return state;