Commit bbdc2173 authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

Small code fixes in login actions/reducers

parent e43a69c9
......@@ -13,7 +13,6 @@ const defaultAvatar = `${url}/static/members/images/default-avatar.jpg`;
export function loginSuccess(username, token, displayName, photo) {
return {
type: types.LOGINSUCCESS,
loginState: 'loggedIn',
username,
token,
displayName,
......@@ -24,14 +23,18 @@ export function loginSuccess(username, token, displayName, photo) {
export function loginProgress() {
return {
type: types.LOGINPROGRESS,
loginState: 'progress',
};
}
export function loginFailure() {
return {
type: types.LOGINFAILURE,
loginState: 'failure',
};
}
export function logoutSuccess() {
return {
type: types.LOGOUT,
};
}
......@@ -107,8 +110,6 @@ export function login(user, pass) {
}
export function logout() {
AsyncStorage.multiRemove([USERNAMEKEY, TOKENKEY]);
return {
type: types.LOGOUT,
};
return dispatch => AsyncStorage.multiRemove([USERNAMEKEY, TOKENKEY])
.then(dispatch(logoutSuccess()));
}
......@@ -13,7 +13,7 @@ export default function navigate(state = initialState, action = {}) {
switch (action.type) {
case types.LOGINSUCCESS: {
return {
...initialState,
...state,
loggedIn: true,
};
}
......
......@@ -24,7 +24,7 @@ export default function session(state = initialState, action = {}) {
case types.LOGINPROGRESS:
return { ...state, loginState: 'progress' };
case types.LOGOUT:
return { ...state, loginState: 'logout' };
return { ...initialState, loginState: 'logout' };
default:
return state;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment