Update error message for password complexity API

What does this MR do and why?

Related to #478229 (closed).

This MR address this discussion about the error message when password complexity validation failed:

thought: - I think having a more descriptive error message would help here. Especially since it is related to an API request at this point, so letting the user know that it might be down, or the network connection should be checked, would help.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Before After
Screenshot_2025-01-17_at_9.54.38_AM Screenshot_2025-01-17_at_2.50.29_PM

How to set up and validate locally

  1. Enable display_password_requirements feature flag
  2. Apply this diff to simulate failed request.
diff --git a/ee/app/assets/javascripts/api/users_api.js b/ee/app/assets/javascripts/api/users_api.js
index f27fcaaca91a..10ebfb1e029c 100644
--- a/ee/app/assets/javascripts/api/users_api.js
+++ b/ee/app/assets/javascripts/api/users_api.js
@@ -6,5 +6,6 @@ export const PASSWORD_COMPLEXITY_PATH = '/users/password/complexity';
 export function validatePasswordComplexity(newUserParams) {
   const url = buildApiUrl(PASSWORD_COMPLEXITY_PATH);
 
-  return axios.post(url, { user: newUserParams });
+  // return axios.post(url, { user: newUserParams });
+  return Promise.reject(new Error());
 }
  1. Go to '/users/sign_up' and type in the password input
  2. The error message should render.
Edited by Roy Liu

Merge request reports

Loading