Front: gestion de la déconnexion

This commit is contained in:
2020-02-19 13:51:14 +01:00
parent eda015a5ec
commit 25c78caa68
7 changed files with 84 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { LOGIN_SUCCESS } from "../actions/auth.actions";
import { LOGIN_SUCCESS, LOGOUT_SUCCESS } from "../actions/auth.actions";
const initialState = {
isLoggedIn: false,
@ -9,6 +9,8 @@ export function sessionReducer(state = initialState, action) {
switch(action.type) {
case LOGIN_SUCCESS:
return handleLoginSuccess(state, action);
case LOGOUT_SUCCESS:
return handleLogoutSuccess(state, action);
};
return state;
}
@ -21,4 +23,12 @@ function handleLoginSuccess(state, action) {
username: action.username,
},
}
};
function handleLogoutSuccess(state, action) {
return {
...state,
isLoggedIn: false,
user: null,
}
};