<commit_before>import { REHYDRATE } from 'redux-persist/constants'
import * as ACTION_TYPES from '../constants/action_types'
import session from '../vendor/session'

const initialState = {
  isLoggedIn: false,
  accessToken: null,
  tokenType: null,
  expirationDate: null,
  expiresIn: null,
  createdAt: null,
  refreshToken: null,
  refreshTimeoutId: null,
}

export function authentication(state = initialState, action) {
  const { payload } = action
  switch (action.type) {
    case ACTION_TYPES.AUTHENTICATION.SCHEDULE_REFRESH:
      return { ...state, refreshTimeoutId: action.payload.refreshTimeoutId }
    case ACTION_TYPES.AUTHENTICATION.CANCEL_REFRESH:
      return { ...state, refreshTimeoutId: null }
    case ACTION_TYPES.AUTHENTICATION.LOGOUT_SUCCESS:
    case ACTION_TYPES.AUTHENTICATION.LOGOUT_FAILURE:
      session.clear()
      return { ...initialState }
    case ACTION_TYPES.PROFILE.DELETE_SUCCESS:
      return { ...initialState }
    case ACTION_TYPES.AUTHENTICATION.USER_SUCCESS:
    case ACTION_TYPES.AUTHENTICATION.REFRESH_SUCCESS:
    case ACTION_TYPES.PROFILE.SIGNUP_SUCCESS:
      return {
        ...state,
        ...payload.response,
        expirationDate: new Date((payload.response.createdAt + payload.response.expiresIn) * 1000),
        isLoggedIn: true,
      }
    case REHYDRATE:
      // Don't take the timeout ID from localstorage
      if (payload.authentication) {
        return {
          ...payload.authentication,
          refreshTimeoutId: state.refreshTimeoutId,
        }
      }
      return state
    default:
      return state
  }
}
<commit_msg>Adds the expiration date to the rehydrate action.<commit_after>import { REHYDRATE } from 'redux-persist/constants'
import * as ACTION_TYPES from '../constants/action_types'
import session from '../vendor/session'

const initialState = {
  isLoggedIn: false,
  accessToken: null,
  tokenType: null,
  expirationDate: null,
  expiresIn: null,
  createdAt: null,
  refreshToken: null,
  refreshTimeoutId: null,
}

export function authentication(state = initialState, action) {
  const { authentication: auth, response } = action.payload
  switch (action.type) {
    case ACTION_TYPES.AUTHENTICATION.SCHEDULE_REFRESH:
      return { ...state, refreshTimeoutId: action.payload.refreshTimeoutId }
    case ACTION_TYPES.AUTHENTICATION.CANCEL_REFRESH:
      return { ...state, refreshTimeoutId: null }
    case ACTION_TYPES.AUTHENTICATION.LOGOUT_SUCCESS:
    case ACTION_TYPES.AUTHENTICATION.LOGOUT_FAILURE:
      session.clear()
      return { ...initialState }
    case ACTION_TYPES.PROFILE.DELETE_SUCCESS:
      return { ...initialState }
    case ACTION_TYPES.AUTHENTICATION.USER_SUCCESS:
    case ACTION_TYPES.AUTHENTICATION.REFRESH_SUCCESS:
    case ACTION_TYPES.PROFILE.SIGNUP_SUCCESS:
      return {
        ...state,
        ...response,
        expirationDate: new Date((response.createdAt + response.expiresIn) * 1000),
        isLoggedIn: true,
      }
    case REHYDRATE:
      // Don't take the timeout ID from localstorage
      if (auth) {
        return {
          ...auth,
          refreshTimeoutId: state.refreshTimeoutId,
          expirationDate: new Date((auth.createdAt + auth.expiresIn) * 1000),
        }
      }
      return state
    default:
      return state
  }
}

{'fraction_non_alphanumeric': 0.09565745520801701, 'fraction_numerical': 0.0036440935317339812, 'mean_word_length': 3.0268948655256724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5192391', 'n_tokens_mistral': 998, 'n_tokens_neox': 1009, 'n_words': 214}