Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Show error in change password modal if input is empty.

Sahil Batraaebbbcd03d0e
diff --git a/static/js/settings_account.js b/static/js/settings_account.js
index a5fa3a17a8e..6de16bb7a2e 100644
--- a/static/js/settings_account.js
+++ b/static/js/settings_account.js
@@ -459,12 +459,29 @@ export function set_up() {
e.preventDefault();
e.stopPropagation();
const change_password_error = $("#change_password_modal").find("#dialog_error");
+ change_password_error.hide();
const data = {
old_password: $("#old_password").val(),
new_password: $("#new_password").val(),
};
+ function show_error_message(rendered_error_msg) {
+ change_password_error.html(rendered_error_msg);
+ change_password_error.addClass("alert-error").show();
+ dialog_widget.hide_dialog_spinner();
+ }
+
+ if (data.old_password === "") {
+ show_error_message($t_html({defaultMessage: "Please enter your password"}));
+ return;
+ }
+
+ if (data.new_password === "") {
+ show_error_message($t_html({defaultMessage: "Please choose a new password"}));
+ return;
+ }
+
const new_pw_field = $("#new_password");
const new_pw = data.new_password;
if (new_pw !== "") {