diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js
index 54970ba60..a1a44611f 100644
--- a/client/coral-framework/actions/auth.js
+++ b/client/coral-framework/actions/auth.js
@@ -1,3 +1,6 @@
+import I18n from 'coral-framework/modules/i18n/i18n';
+import translations from './../translations';
+const lang = new I18n(translations);
import * as actions from '../constants/auth';
import {base, handleResp, getInit} from '../helpers/response';
@@ -27,7 +30,7 @@ export const fetchSignIn = (formData) => dispatch => {
dispatch(hideSignInDialog());
dispatch(signInSuccess(user));
})
- .catch(() => dispatch(signInFailure('Email and/or password combination incorrect.')));
+ .catch(() => dispatch(signInFailure(lang.t('error.emailPasswordError'))));
};
// Sign In - Facebook
@@ -75,7 +78,7 @@ export const fetchSignUp = formData => dispatch => {
dispatch(changeView('SIGNIN'));
}, 3000);
})
- .catch((error) => dispatch(signUpFailure(error)));
+ .catch(() => dispatch(signUpFailure(lang.t('error.emailInUse')))); // We need to inprove error handling. TODO (bc)
};
// Forgot Password Actions
@@ -106,3 +109,8 @@ export const logout = () => dispatch => {
.catch(error => dispatch(logOutFailure(error)));
};
+// LogOut Actions
+
+export const validForm = () => ({type: actions.VALID_FORM});
+export const invalidForm = error => ({type: actions.INVALID_FORM, error});
+
diff --git a/client/coral-framework/constants/auth.js b/client/coral-framework/constants/auth.js
index 5c0135f58..a6a2c44f8 100644
--- a/client/coral-framework/constants/auth.js
+++ b/client/coral-framework/constants/auth.js
@@ -24,9 +24,6 @@ export const LOGOUT_REQUEST = 'LOGOUT_REQUEST';
export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS';
export const LOGOUT_FAILURE = 'LOGOUT_FAILURE';
-export const FETCH_AVAILABILITY_REQUEST = 'FETCH_AVAILABILITY_REQUEST';
-export const FETCH_AVAILABILITY_SUCCESS = 'FETCH_AVAILABILITY_SUCCESS';
-export const FETCH_AVAILABILITY_FAILURE = 'FETCH_AVAILABILITY_FAILURE';
+export const INVALID_FORM = 'INVALID_FORM';
+export const VALID_FORM = 'VALID_FORM';
-export const AVAILABLE_FIELD = 'AVAILABLE_FIELD';
-export const UNAVAILABLE_FIELD = 'UNAVAILABLE_FIELD';
diff --git a/client/coral-framework/helpers/error.js b/client/coral-framework/helpers/error.js
index 2a48c056d..34ba253ba 100644
--- a/client/coral-framework/helpers/error.js
+++ b/client/coral-framework/helpers/error.js
@@ -1,5 +1,5 @@
import I18n from 'coral-framework/modules/i18n/i18n';
-import translations from './translations';
+import translations from './../translations';
const lang = new I18n(translations);
export default {
diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js
index 6dc59a019..3e454892f 100644
--- a/client/coral-framework/reducers/auth.js
+++ b/client/coral-framework/reducers/auth.js
@@ -7,8 +7,7 @@ const initialState = Map({
user: null,
showSignInDialog: false,
view: 'SIGNIN',
- signUpError: '',
- emailAvailable: true,
+ error: '',
successSignUp: false
});
@@ -22,14 +21,12 @@ export default function auth (state = initialState, action) {
isLoading: false,
showSignInDialog: false,
view: 'SIGNIN',
- signInError: '',
- signUpError: '',
- emailAvailable: true,
+ error: '',
successSignUp: false
}));
case actions.CHANGE_VIEW :
return state
- .set('signInError', '')
+ .set('error', '')
.set('view', action.view);
case actions.CLEAN_STATE:
return initialState;
@@ -43,7 +40,7 @@ export default function auth (state = initialState, action) {
case actions.FETCH_SIGNIN_FAILURE:
return state
.set('isLoading', false)
- .set('signInError', action.error);
+ .set('error', action.error);
case actions.FETCH_SIGNIN_FACEBOOK_SUCCESS:
return state
.set('user', action.user)
@@ -57,6 +54,7 @@ export default function auth (state = initialState, action) {
.set('isLoading', true);
case actions.FETCH_SIGNUP_FAILURE:
return state
+ .set('error', action.error)
.set('isLoading', false);
case actions.FETCH_SIGNUP_SUCCESS:
return state
@@ -66,6 +64,12 @@ export default function auth (state = initialState, action) {
return state
.set('loggedIn', false)
.set('user', null);
+ case actions.INVALID_FORM:
+ return state
+ .set('error', action.error);
+ case actions.VALID_FORM:
+ return state
+ .set('error', '');
default :
return state;
}
diff --git a/client/coral-framework/helpers/translations.json b/client/coral-framework/translations.json
similarity index 59%
rename from client/coral-framework/helpers/translations.json
rename to client/coral-framework/translations.json
index f8ba0d35f..4abd1ed03 100644
--- a/client/coral-framework/helpers/translations.json
+++ b/client/coral-framework/translations.json
@@ -4,7 +4,9 @@
"email": "Not a valid E-Mail",
"password": "Password must be at least 8 characters",
"displayName": "Display name is too short",
- "confirmPassword": "Passwords don`t match. Please, check again"
+ "confirmPassword": "Passwords don`t match. Please, check again",
+ "emailPasswordError": "Email and/or password combination incorrect.",
+ "emailInUse": "Email address already in use"
}
},
"es": {
@@ -12,7 +14,9 @@
"email": "No es un email válido",
"password": "La contraseña debe tener por lo menos 8 caracteres",
"displayName": "El nombre es muy corto",
- "confirmPassword": "Las contraseñas no coinciden"
+ "confirmPassword": "Las contraseñas no coinciden",
+ "emailPasswordError": "Email y/o contraseña incorrecta.",
+ "emailInUse": "Email address already in use"
}
}
-}
+}
\ No newline at end of file
diff --git a/client/coral-sign-in/components/SignInContent.js b/client/coral-sign-in/components/SignInContent.js
index 8aa688133..76a93f56c 100644
--- a/client/coral-sign-in/components/SignInContent.js
+++ b/client/coral-sign-in/components/SignInContent.js
@@ -25,7 +25,7 @@ const SignInContent = ({handleChange, formData, ...props}) => (
{lang.t('signIn.or')}
- { props.auth.signInError &&