Logins and logouts (sessions) are working

This commit is contained in:
2019-05-08 11:35:57 +10:00
parent 0d4bb2f57f
commit fbb37ad2d9
15 changed files with 477 additions and 74 deletions
+29
View File
@@ -0,0 +1,29 @@
import { LOGIN, LOGOUT } from "../actions/accounts.js";
const initialStore = {
id: 0,
email: '',
username: '',
token: 0
};
export function accountReducer(store = initialStore, action) {
switch(action.type) {
case LOGIN:
let newStore = JSON.parse(JSON.stringify(initialStore));
newStore.id = action.id;
newStore.email = action.email;
newStore.username = action.username;
newStore.token = action.token;
return newStore;
case LOGOUT:
return initialStore;
default:
return store;
}
}
+8
View File
@@ -0,0 +1,8 @@
import { combineReducers } from 'redux';
import { accountReducer } from './accounts.js';
//compile all reducers together
export default combineReducers({
account: accountReducer
});
-14
View File
@@ -1,14 +0,0 @@
import { ACTION_NAME } from "../actions/actions.jsx";
const initialState = {};
export default function reducer(state = initialState, action) {
switch(action.type) {
case ACTION_NAME:
//DO NOTHING
return state;
default:
return state;
}
}