You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.ts 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import ReducerRegistry from '../redux/ReducerRegistry';
  2. import { equals } from '../redux/functions';
  3. import { SET_JWT } from './actionTypes';
  4. export interface IJwtState {
  5. callee?: {
  6. name: string;
  7. };
  8. group?: string;
  9. jwt?: string;
  10. server?: string;
  11. tenant?: string;
  12. user?: {
  13. name: string;
  14. };
  15. }
  16. /**
  17. * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
  18. * redux store.
  19. *
  20. * @param {Object} state - The current redux state.
  21. * @param {Object} action - The redux action to reduce.
  22. * @returns {Object} The next redux state which is the result of reducing the
  23. * specified {@code action}.
  24. */
  25. ReducerRegistry.register<IJwtState>(
  26. 'features/base/jwt',
  27. (state = {}, action): IJwtState => {
  28. switch (action.type) {
  29. case SET_JWT: {
  30. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  31. const { type, ...payload } = action;
  32. const nextState = {
  33. ...payload
  34. };
  35. return equals(state, nextState) ? state : nextState;
  36. }
  37. }
  38. return state;
  39. });