sforkowany z mirror/soapbox
Skip verify_credentials if there are no credentials
rodzic
f24bd74a38
commit
34bae6a5df
|
@ -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));
|
||||
|
|
|
@ -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:
|
||||
|
|
Ładowanie…
Reference in New Issue