Add API method for clearing existing errors
This commit is contained in:
parent
e473c9af3e
commit
5a34b415f2
13
js/api.js
13
js/api.js
|
|
@ -21,6 +21,8 @@ const actiontypes_userinfo = {
|
||||||
'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS',
|
'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS',
|
||||||
'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR',
|
'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR',
|
||||||
|
|
||||||
|
'CLEAR_ERRORS' : 'CLEAR_ERRORS',
|
||||||
|
|
||||||
'LOGOUT' : 'LOGOUT',
|
'LOGOUT' : 'LOGOUT',
|
||||||
|
|
||||||
'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS',
|
'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS',
|
||||||
|
|
@ -219,6 +221,11 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
|
||||||
error : true,
|
error : true,
|
||||||
errorMessages : action.parameters.errorMessages
|
errorMessages : action.parameters.errorMessages
|
||||||
});
|
});
|
||||||
|
case actiontypes_userinfo.CLEAR_ERRORS:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
error : false,
|
||||||
|
errorMessages : []
|
||||||
|
});
|
||||||
case actiontypes_userinfo.LOGOUT:
|
case actiontypes_userinfo.LOGOUT:
|
||||||
deleteRequest(action.state, '/users/sign_out').then(() => {
|
deleteRequest(action.state, '/users/sign_out').then(() => {
|
||||||
__store.dispatch({ type : actiontypes_userinfo.CLEAR });
|
__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) {
|
export function register(username, email, password) {
|
||||||
__store.dispatch({
|
__store.dispatch({
|
||||||
type: actiontypes_userinfo.REGISTER,
|
type: actiontypes_userinfo.REGISTER,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue