diff --git a/js/api.js b/js/api.js index 84ae430..79ffa4e 100644 --- a/js/api.js +++ b/js/api.js @@ -21,6 +21,8 @@ const actiontypes_userinfo = { 'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS', 'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR', + 'CLEAR_ERRORS' : 'CLEAR_ERRORS', + 'LOGOUT' : 'LOGOUT', 'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS', @@ -219,6 +221,11 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => { error : true, errorMessages : action.parameters.errorMessages }); + case actiontypes_userinfo.CLEAR_ERRORS: + return Object.assign({}, state, { + error : false, + errorMessages : [] + }); case actiontypes_userinfo.LOGOUT: deleteRequest(action.state, '/users/sign_out').then(() => { __store.dispatch({ type : actiontypes_userinfo.CLEAR }); @@ -348,6 +355,12 @@ export function verifyCredentials() { } } +export function clearErrors() { + __store.dispatch({ + type: actiontypes_userinfo.CLEAR_ERRORS + }); +} + export function register(username, email, password) { __store.dispatch({ type: actiontypes_userinfo.REGISTER,