connected-react-router#go JavaScript Examples

The following examples show how to use connected-react-router#go. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From HexactaLabs-NetCore_React-Initial with Apache License 2.0 6 votes vote down vote up
login = ({ username, password }) => dispatch => {
  dispatch({ type: AUTH_REQUEST });

  if (username === password && username === "admin") {
    localStorage.setItem("JWT_LOGIN", "ESTO ES UN JWT DE PRUEBA");
    dispatch(go("/"));
    dispatch({ type: AUTH_RESPONSE });
  } else {
    dispatch({
      type: AUTH_ERROR,
      error:
        "Las credenciales no son correctas, intente nuevamente. (admin,admin)"
    });
  }

  // const url = '/authenticate';

  // api.post(url, { username: username, password: password })
  //     .then((response, ...other) => {
  //         localStorage.setItem('JWT_LOGIN', response.data)
  //         dispatch(go('/'))
  //         dispatch({ type: AUTH_RESPONSE, payload: response.data })
  //     })
  //     .catch(() => {
  //         //toast.error('OcurriĆ³ un error');
  //         dispatch({ type: AUTH_ERROR, error: 'Las credenciales no son correctas, intente nuevamente.' })
  //     });
}