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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. id: string;
  14. name: string;
  15. };
  16. }
  17. /**
  18. * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
  19. * redux store.
  20. *
  21. * @param {Object} state - The current redux state.
  22. * @param {Object} action - The redux action to reduce.
  23. * @returns {Object} The next redux state which is the result of reducing the
  24. * specified {@code action}.
  25. */
  26. ReducerRegistry.register<IJwtState>(
  27. 'features/base/jwt',
  28. (state = {}, action): IJwtState => {
  29. switch (action.type) {
  30. case SET_JWT: {
  31. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  32. const { type, ...payload } = action;
  33. const nextState = {
  34. ...payload
  35. };
  36. return equals(state, nextState) ? state : nextState;
  37. }
  38. }
  39. return state;
  40. });