mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
35 lines
853 B
JavaScript
Executable file
35 lines
853 B
JavaScript
Executable file
import { getAccessToken } from '../utils/access-token-storage';
|
|
import ActionTypes from '../constants/ActionTypes';
|
|
|
|
const initialState = {
|
|
accessToken: getAccessToken(),
|
|
userId: null,
|
|
};
|
|
|
|
// eslint-disable-next-line default-param-last
|
|
export default (state = initialState, { type, payload }) => {
|
|
switch (type) {
|
|
case ActionTypes.AUTHENTICATE__SUCCESS:
|
|
return {
|
|
...state,
|
|
accessToken: payload.accessToken,
|
|
};
|
|
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
|
case ActionTypes.CORE_INITIALIZE:
|
|
return {
|
|
...state,
|
|
userId: payload.user.id,
|
|
};
|
|
case ActionTypes.USER_PASSWORD_UPDATE__SUCCESS:
|
|
if (payload.accessToken) {
|
|
return {
|
|
...state,
|
|
accessToken: payload.accessToken,
|
|
};
|
|
}
|
|
|
|
return state;
|
|
default:
|
|
return state;
|
|
}
|
|
};
|