mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
feat: Invalidate access token on logout
This commit is contained in:
parent
f091de6827
commit
48ea62c0a0
26 changed files with 242 additions and 37 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue