Ajout page d'authentification
This commit is contained in:
24
frontend/src/reducers/session.reducers.js
Normal file
24
frontend/src/reducers/session.reducers.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { LOGIN_SUCCESS } from "../actions/auth.actions";
|
||||
|
||||
const initialState = {
|
||||
isLoggedIn: false,
|
||||
user: null,
|
||||
};
|
||||
|
||||
export function sessionReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
return handleLoginSuccess(state, action);
|
||||
};
|
||||
return state;
|
||||
}
|
||||
|
||||
function handleLoginSuccess(state, action) {
|
||||
return {
|
||||
...state.user,
|
||||
isLoggedIn: true,
|
||||
user: {
|
||||
username: action.username,
|
||||
},
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user