Initial git
This commit is contained in:
52
app/reducers/authorizeReducer.jsx
Normal file
52
app/reducers/authorizeReducer.jsx
Normal file
@@ -0,0 +1,52 @@
|
||||
// - Import action types
|
||||
import * as types from 'actionTypes'
|
||||
|
||||
|
||||
/**
|
||||
* Default state
|
||||
*/
|
||||
var defaultState = {
|
||||
uid: 0,
|
||||
authed: false,
|
||||
updatePassword: false,
|
||||
guest:false
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Authorize reducer
|
||||
* @param {object} state
|
||||
* @param {object} action
|
||||
*/
|
||||
export var authorizeReducer = (state = defaultState, action) =>{
|
||||
switch (action.type) {
|
||||
case types.LOGIN:
|
||||
return{
|
||||
uid: action.uid,
|
||||
authed: true,
|
||||
guest:false
|
||||
}
|
||||
case types.LOGOUT:
|
||||
return{
|
||||
...state,
|
||||
uid: 0,
|
||||
authed: false,
|
||||
guest:true
|
||||
}
|
||||
|
||||
case types.SIGNUP:
|
||||
return{
|
||||
...state,
|
||||
uid: action.uid
|
||||
}
|
||||
case types.UPDATE_PASSWORD:
|
||||
return{
|
||||
...state,
|
||||
updatePassword: action.updatePassword
|
||||
}
|
||||
default:
|
||||
return state
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user