|
|
@ -133,15 +133,20 @@ export function logOut() {
|
|
|
|
export function register(params) {
|
|
|
|
export function register(params) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const needsConfirmation = getState().getIn(['instance', 'pleroma', 'metadata', 'account_activation_required']);
|
|
|
|
const needsConfirmation = getState().getIn(['instance', 'pleroma', 'metadata', 'account_activation_required']);
|
|
|
|
|
|
|
|
const needsApproval = getState().getIn(['instance', 'approval_required']);
|
|
|
|
dispatch({ type: AUTH_REGISTER_REQUEST });
|
|
|
|
dispatch({ type: AUTH_REGISTER_REQUEST });
|
|
|
|
return dispatch(createAppAndToken()).then(() => {
|
|
|
|
return dispatch(createAppAndToken()).then(() => {
|
|
|
|
return api(getState, 'app').post('/api/v1/accounts', params);
|
|
|
|
return api(getState, 'app').post('/api/v1/accounts', params);
|
|
|
|
}).then(response => {
|
|
|
|
}).then(response => {
|
|
|
|
dispatch({ type: AUTH_REGISTER_SUCCESS, token: response.data });
|
|
|
|
dispatch({ type: AUTH_REGISTER_SUCCESS, token: response.data });
|
|
|
|
dispatch(authLoggedIn(response.data));
|
|
|
|
dispatch(authLoggedIn(response.data));
|
|
|
|
return needsConfirmation
|
|
|
|
if (needsConfirmation) {
|
|
|
|
? dispatch(showAlert('', 'Check your email for further instructions.'))
|
|
|
|
return dispatch(showAlert('', 'Check your email for further instructions.'));
|
|
|
|
: dispatch(fetchMe());
|
|
|
|
} else if (needsApproval) {
|
|
|
|
|
|
|
|
return dispatch(showAlert('', 'Your account has been submitted for approval.'));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return dispatch(fetchMe());
|
|
|
|
|
|
|
|
}
|
|
|
|
}).catch(error => {
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch({ type: AUTH_REGISTER_FAIL, error });
|
|
|
|
dispatch({ type: AUTH_REGISTER_FAIL, error });
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|