How to use the react-jhipster.Storage.session function in react-jhipster

To help you get started, we’ve selected a few react-jhipster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhipster / jhipster-sample-app-react / src / main / webapp / app / shared / reducers / authentication.ts View on Github external
export const clearAuthToken = () => {
  if (Storage.local.get(AUTH_TOKEN_KEY)) {
    Storage.local.remove(AUTH_TOKEN_KEY);
  }
  if (Storage.session.get(AUTH_TOKEN_KEY)) {
    Storage.session.remove(AUTH_TOKEN_KEY);
  }
};
github jhipster / jhipster-sample-app-react / src / main / webapp / app / shared / reducers / authentication.ts View on Github external
export const getSession = () => async (dispatch, getState) => {
  await dispatch({
    type: ACTION_TYPES.GET_SESSION,
    payload: axios.get('api/account')
  });

  const { account } = getState().authentication;
  if (account && account.langKey) {
    const langKey = Storage.session.get('locale', account.langKey);
    await dispatch(setLocale(langKey));
  }
};
github jhipster / jhipster-sample-app-react / src / main / webapp / app / shared / reducers / authentication.ts View on Github external
export const clearAuthToken = () => {
  if (Storage.local.get(AUTH_TOKEN_KEY)) {
    Storage.local.remove(AUTH_TOKEN_KEY);
  }
  if (Storage.session.get(AUTH_TOKEN_KEY)) {
    Storage.session.remove(AUTH_TOKEN_KEY);
  }
};
github dongyanghe / eikesi / x-im-web / src / main / webapp / app / shared / reducers / locale.ts View on Github external
export default (state: LocaleState = initialState, action): LocaleState => {
  switch (action.type) {
    case ACTION_TYPES.SET_LOCALE:
      const currentLocale = action.locale;
      if (state.currentLocale !== currentLocale) {
        Storage.session.set('locale', currentLocale);
        TranslatorContext.setLocale(currentLocale);
      }
      return {
        currentLocale
      };
    default:
      return state;
  }
};
github jhipster / jhipster-sample-app-react / src / main / webapp / app / modules / account / settings / settings.reducer.ts View on Github external
export const saveAccountSettings = account => async (dispatch, getState) => {
  await dispatch({
    type: ACTION_TYPES.UPDATE_ACCOUNT,
    payload: axios.post(apiUrl, account),
    meta: {
      successMessage: translate('settings.messages.success')
    }
  });

  if (Storage.session.get(`locale`)) {
    Storage.session.remove(`locale`);
  }

  await dispatch(getSession());
};
github jhipster / jhipster-sample-app-react / src / main / webapp / app / shared / layout / header / header.tsx View on Github external
const handleLocaleChange = event => {
    const langKey = event.target.value;
    Storage.session.set('locale', langKey);
    props.onLocaleChange(langKey);
  };
github oktadeveloper / okta-react-native-spring-boot-example / jhipster-api / src / main / webapp / app / shared / reducers / authentication.ts View on Github external
export const getSession = () => async (dispatch, getState) => {
  await dispatch({
    type: ACTION_TYPES.GET_SESSION,
    payload: axios.get('api/account')
  });

  const { account } = getState().authentication;
  if (account && account.langKey) {
    const langKey = Storage.session.get('locale', account.langKey);
    await dispatch(setLocale(langKey));
  }
};
github xebialabs / e-commerce-microservice / store / src / main / webapp / app / config / translation.ts View on Github external
export const registerLocale = store => {
  store.dispatch(setLocale(Storage.session.get('locale', 'en')));
};
github jhipster / jhipster-sample-app-react / src / main / webapp / app / config / translation.ts View on Github external
export const registerLocale = store => {
  store.dispatch(setLocale(Storage.session.get('locale', 'en')));
};