diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-03-05 21:34:34 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-03-05 21:34:34 +0100 |
| commit | 88d092e21a4ea296ce804ef416683807df4b7d38 (patch) | |
| tree | 53e85f1e415cfc298f814d52029516c1a33de712 /animism-align/frontend/app/views/auth/auth.reducer.js | |
| parent | 0907418ce2c6ca498b02e8e514e4945d79750467 (diff) | |
change password. log in
Diffstat (limited to 'animism-align/frontend/app/views/auth/auth.reducer.js')
| -rw-r--r-- | animism-align/frontend/app/views/auth/auth.reducer.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/auth/auth.reducer.js b/animism-align/frontend/app/views/auth/auth.reducer.js new file mode 100644 index 0000000..05741f3 --- /dev/null +++ b/animism-align/frontend/app/views/auth/auth.reducer.js @@ -0,0 +1,40 @@ +import * as types from 'app/types' +import { getDefault } from 'app/session' + +const initialState = { + logged_in: !!getDefault('access_token', false), + user_id: null, + user: null, +} + +export default function authReducer(state = initialState, action) { + // console.log(action.type, action) + switch (action.type) { + case types.auth.logged_in: + return { + ...state, + logged_in: true, + user_id: action.user_id, + user: null, + } + case types.auth.logged_out: + return { + ...state, + logged_in: false, + user_id: null, + user: null, + } + case types.user.show: + if (action.data.res.id !== state.user_id) { + return state + } + return { + ...state, + user: { + ...action.data.res, + } + } + default: + return state + } +} |
