mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-25 15:33:04 +00:00
add a sample AuthorizationServer to the repo and put traffic-police app in a separate folder
This commit is contained in:
38
React/traffic-police/src/reducers/authReducer.js
Normal file
38
React/traffic-police/src/reducers/authReducer.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
USER_SIGNED_OUT,
|
||||
STORE_USER_ERROR,
|
||||
USER_EXPIRED,
|
||||
STORE_USER,
|
||||
LOADING_USER
|
||||
} from '../actions/types'
|
||||
|
||||
const initialState = {
|
||||
user: null,
|
||||
isLoadingUser: false
|
||||
};
|
||||
|
||||
export default function (state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case STORE_USER:
|
||||
return {
|
||||
...state,
|
||||
isLoadingUser: false,
|
||||
user: action.payload
|
||||
}
|
||||
case LOADING_USER:
|
||||
return {
|
||||
...state,
|
||||
isLoadingUser: true
|
||||
}
|
||||
case USER_EXPIRED:
|
||||
case STORE_USER_ERROR:
|
||||
case USER_SIGNED_OUT:
|
||||
return {
|
||||
...state,
|
||||
user: null,
|
||||
isLoadingUser: false
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
6
React/traffic-police/src/reducers/index.js
Normal file
6
React/traffic-police/src/reducers/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { combineReducers } from 'redux';
|
||||
import authReducer from './authReducer';
|
||||
|
||||
export default combineReducers({
|
||||
auth: authReducer
|
||||
})
|
||||
Reference in New Issue
Block a user