Front: gestion de la déconnexion
This commit is contained in:
@ -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,
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user