mirror of
https://github.com/plankanban/planka.git
synced 2025-12-19 17:23:27 +03:00
feat: Invalidate access token on logout
This commit is contained in:
@@ -1,18 +1,34 @@
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user