From 8686c0418bd471ada8aa56bad14a6ff9a4b820ca Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 5 Oct 2017 15:19:29 +1300 Subject: [PATCH] validate confirm password field on every change --- subiquity/ui/views/identity.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subiquity/ui/views/identity.py b/subiquity/ui/views/identity.py index 1948d4aa..411c43c2 100644 --- a/subiquity/ui/views/identity.py +++ b/subiquity/ui/views/identity.py @@ -104,6 +104,7 @@ class IdentityView(BaseView): self.form = IdentityForm() connect_signal(self.form, 'submit', self.done) + connect_signal(self.form.confirm_password.widget, 'change', self._check_password) self.ssh_import_confirmed = True @@ -114,6 +115,13 @@ class IdentityView(BaseView): ] super().__init__(ListBox(body)) + def _check_password(self, sender, new_text): + password = self.form.password.value + if not password.startswith(new_text): + self.form.confirm_password.show_extra(("info_error", "Passwords do not match")) + else: + self.form.confirm_password.show_extra('') + def done(self, result): cpassword = self.model.encrypt_password(self.form.password.value) log.debug("*crypted* User input: {} {} {}".format(