mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* consistent error handling * Display server errors in InviteUserForm * Handle errors in Form component * Refactors query form * creates KolideAce component * Renders QueryForm from query page and manage hosts page * Moves ace editor and select targets dropdown to query form * Render base errors in Form HOC * LoginPage and ForgotPasswordPage server errors * Ensure unique key for user blocks * Adds base error to login form and forgot password form * Adds base error to query form * Adds base error to Pack Form * Adds errors to confirm invite form * Adds clearErrors action * clear errors when confirm invite page unmounts * Handle errors in the App Setting page * Handle server errors in the User Settings Page * Handle server errors in the User Management Page
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import Kolide from 'kolide';
|
|
import { formatErrorResponse } from 'redux/nodes/entities/base/helpers';
|
|
|
|
export const CLEAR_FORGOT_PASSWORD_ERRORS = 'CLEAR_FORGOT_PASSWORD_ERRORS';
|
|
export const FORGOT_PASSWORD_REQUEST = 'FORGOT_PASSWORD_REQUEST';
|
|
export const FORGOT_PASSWORD_SUCCESS = 'FORGOT_PASSWORD_SUCCESS';
|
|
export const FORGOT_PASSWORD_ERROR = 'FORGOT_PASSWORD_ERROR';
|
|
|
|
export const clearForgotPasswordErrors = { type: CLEAR_FORGOT_PASSWORD_ERRORS };
|
|
export const forgotPasswordRequestAction = { type: FORGOT_PASSWORD_REQUEST };
|
|
export const forgotPasswordSuccessAction = (email) => {
|
|
return {
|
|
type: FORGOT_PASSWORD_SUCCESS,
|
|
payload: {
|
|
data: {
|
|
email,
|
|
},
|
|
},
|
|
};
|
|
};
|
|
export const forgotPasswordErrorAction = (errors) => {
|
|
return {
|
|
type: FORGOT_PASSWORD_ERROR,
|
|
payload: {
|
|
errors,
|
|
},
|
|
};
|
|
};
|
|
|
|
// formData should be { email: <string> }
|
|
export const forgotPasswordAction = (formData) => {
|
|
return (dispatch) => {
|
|
dispatch(forgotPasswordRequestAction);
|
|
|
|
return Kolide.forgotPassword(formData)
|
|
.then(() => {
|
|
const { email } = formData;
|
|
|
|
return dispatch(forgotPasswordSuccessAction(email));
|
|
})
|
|
.catch((response) => {
|
|
const errorObject = formatErrorResponse(response);
|
|
|
|
dispatch(forgotPasswordErrorAction(errorObject));
|
|
throw response;
|
|
});
|
|
};
|
|
};
|