Add API method for clearing existing errors

This commit is contained in:
JP1998 2019-04-11 14:07:59 +02:00
parent e473c9af3e
commit 5a34b415f2
1 changed files with 13 additions and 0 deletions

View File

@ -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,