Skip verify_credentials if there are no credentials

stable/1.0.x
Alex Gleason 2020-04-11 18:55:07 -05:00
rodzic f24bd74a38
commit 34bae6a5df
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -4,9 +4,12 @@ import { importFetchedAccount } from './importer';
export const ME_FETCH_REQUEST = 'ME_FETCH_REQUEST';
export const ME_FETCH_SUCCESS = 'ME_FETCH_SUCCESS';
export const ME_FETCH_FAIL = 'ME_FETCH_FAIL';
export const ME_FETCH_SKIP = 'ME_FETCH_SKIP';
export function fetchMe() {
return (dispatch, getState) => {
const accessToken = getState().getIn(['auth', 'user', 'access_token']);
if (!accessToken) return dispatch({type: ME_FETCH_SKIP});
dispatch(fetchMeRequest());
api(getState).get(`/api/v1/accounts/verify_credentials`).then(response => {
dispatch(fetchMeSuccess(response.data));

Wyświetl plik

@ -1,4 +1,4 @@
import { ME_FETCH_SUCCESS, ME_FETCH_FAIL } from '../actions/me';
import { ME_FETCH_SUCCESS, ME_FETCH_FAIL, ME_FETCH_SKIP } from '../actions/me';
import { AUTH_LOGGED_OUT } from '../actions/auth';
import { Map as ImmutableMap, fromJS } from 'immutable';
@ -10,6 +10,8 @@ export default function me(state = initialState, action) {
return fromJS(action.me.id);
case ME_FETCH_FAIL:
return false;
case ME_FETCH_SKIP:
return false;
case AUTH_LOGGED_OUT:
return false;
default: