Philipp Hörist pushed to branch master at gajim / gajim


Commits:
a700f4da by Philipp Hörist at 2026-06-05T14:03:11+02:00
imprv: ChangePassword: Require current password before change

- - - - -


1 changed file:

- gajim/gtk/change_password.py


Changes:

=====================================
gajim/gtk/change_password.py
=====================================
@@ -39,13 +39,16 @@ def __init__(self, account: str) -> None:
         self._client = app.get_client(account)
         self._destroyed = False
 
+        cur_password = passwords.get_password(self.account)
+        assert cur_password is not None
+
         self.add_button("apply", _("Change"), "suggested-action", 
complete=True)
         self.add_button("close", _("Close"))
         self.add_button("back", _("Back"))
 
         self.add_pages(
             {
-                "password": EnterPassword(),
+                "password": EnterPassword(cur_password),
                 "next_stage": NextStage(),
                 "error": Error(),
                 "success": Success(),
@@ -123,10 +126,11 @@ def _cleanup(self) -> None:
 
 
 class EnterPassword(AssistantPage):
-    def __init__(self) -> None:
+    def __init__(self, cur_password: str) -> None:
         AssistantPage.__init__(self)
         self.complete = False
         self.title = _("Change Password")
+        self._cur_password = cur_password
 
         heading = Gtk.Label(
             label=_("Change Password"),
@@ -145,6 +149,13 @@ def __init__(self) -> None:
             margin_bottom=12,
         )
 
+        self._cur_password_entry = Gtk.PasswordEntry(
+            show_peek_icon=True,
+            placeholder_text=_("Enter current password..."),
+            valign=Gtk.Align.END,
+        )
+        self._connect(self._cur_password_entry, "changed", self._on_changed)
+
         self._password1_entry = Gtk.PasswordEntry(
             show_peek_icon=True,
             placeholder_text=_("Enter new password..."),
@@ -168,6 +179,7 @@ def __init__(self) -> None:
 
         self.append(heading)
         self.append(label)
+        self.append(self._cur_password_entry)
         self.append(self._password1_entry)
         self.append(self._password2_entry)
         self.append(box)
@@ -182,6 +194,12 @@ def _show_warning(self, text: str) -> None:
         self._warning_label.set_text(text)
 
     def _on_changed(self, _entry: Gtk.Entry) -> None:
+        cur_password = self._cur_password_entry.get_text()
+        if cur_password != self._cur_password:
+            self._show_warning(_("Current password incorrect"))
+            self._set_complete(False)
+            return
+
         password1 = self._password1_entry.get_text()
         if not password1:
             self._show_warning(_("Passwords do not match"))



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/a700f4da5175d685498ab94f10ad5ca60649dbf5

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/a700f4da5175d685498ab94f10ad5ca60649dbf5
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to