Skip to content

Commit f3165b7

Browse files
author
Travis
committed
Merge branch 'development'
2 parents 72302dd + eb836a2 commit f3165b7

File tree

2 files changed

+3
-44
lines changed

2 files changed

+3
-44
lines changed

app/actions/auth/authActions.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,7 @@
1-
import {getAuthLogin, postUsers, activateUser} from '../../services/authService';
1+
import {getAuthLogin, activateUser} from '../../services/authService';
22
import {Cookies} from 'react-cookie';
33
import * as authActionTypes from './authActionTypes';
44

5-
export const registerIfNeeded = () => {
6-
return (dispatch, getState) => {
7-
if (shouldRegister(getState())) {
8-
return dispatch(registration());
9-
}
10-
return Promise.resolve();
11-
};
12-
};
13-
const shouldRegister = ({auth: {isLoggingIn, isLoggedIn}}) => !isLoggingIn && !isLoggedIn;
14-
const registration = () => {
15-
return (dispatch, getState) => {
16-
dispatch(registrationRequest());
17-
18-
const {auth, app} = getState();
19-
const {registration, activationUrl, activationFromEmail} = auth;
20-
const {appBarTitle} = app;
21-
22-
return postUsers({registration, activationUrl, activationFromEmail, appName: appBarTitle})
23-
.then((response) => {
24-
if (response.status === 201) {
25-
dispatch(registrationSuccess('Account created. We have sent you an email with activation instructions.'));
26-
27-
return {success: true};
28-
} else {
29-
return response.json();
30-
}
31-
})
32-
.then((json) => {
33-
if (json.error && json.errors) {
34-
dispatch(registrationFailure({error: json.error, errors: json.errors}));
35-
}
36-
})
37-
.catch(error => dispatch(registrationFailure({error: error.message, errors: {}})));
38-
};
39-
};
40-
const registrationRequest = () => ({type: authActionTypes.REGISTRATION_REQUEST});
41-
const registrationSuccess = payload => ({type: authActionTypes.REGISTRATION_SUCCESS, payload});
42-
const registrationFailure = payload => ({type: authActionTypes.REGISTRATION_FAILURE, payload});
43-
445
export const loginIfNeeded = () => {
456
return (dispatch, getState) => {
467
const {auth: {isLoggingIn, isLoggedIn, login}} = getState();
@@ -128,11 +89,7 @@ export const setActivationData = () => {
12889
return {type: authActionTypes.SET_ACTIVATION_DATA, payload: {host, hostname, protocol}};
12990
};
13091

131-
export const setRegistrationErrorMessage = payload => ({type: authActionTypes.SET_REGISTRATION_ERROR_MESSAGE, payload});
132-
export const setRegistrationSuccessMessage = payload => ({type: authActionTypes.SET_REGISTRATION_SUCCESS_MESSAGE, payload});
13392
export const setLoginErrorMessage = payload => ({type: authActionTypes.SET_LOGIN_ERROR_MESSAGE, payload});
13493
export const setActivationErrorMessage = payload => ({type: authActionTypes.SET_ACTIVATION_ERROR_MESSAGE, payload});
13594
export const setActivationSuccessMessage = payload => ({type: authActionTypes.SET_ACTIVATION_SUCCESS_MESSAGE, payload});
13695
export const toggleLoginPasswordVisibility = () => ({type: authActionTypes.TOGGLE_LOGIN_PASSWORD_VISIBILITY});
137-
export const toggleRegistrationPasswordVisibility = () => ({type: authActionTypes.TOGGLE_REGISTRATION_PASSWORD_VISIBILITY});
138-
export const toggleRegistrationRepeatPasswordVisibility = () => ({type: authActionTypes.TOGGLE_REGISTRATION_REPEAT_PASSWORD_VISIBILITY});

app/reducers/authReducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const auth = (state = initialState, action) => {
8585
return {...state, showLoginPassword: !state.showLoginPassword};
8686
case authActionTypes.SET_LOGIN_ERROR_MESSAGE:
8787
return {...state, loginErrorMessage: action.payload};
88+
case authActionTypes.SET_ACTIVATION_SUCCESS_MESSAGE:
89+
return {...state, activationSuccessMessage: action.payload};
8890
default:
8991
return state;
9092
}

0 commit comments

Comments
 (0)