From c6628911d4a4c382246e0856b63a0ce67e65988d Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Mon, 28 Sep 2015 11:03:01 -0400 Subject: [PATCH] Add password match validator Signed-off-by: Adam Stokes --- subiquity/palette.py | 2 ++ subiquity/ui/views/identity.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/subiquity/palette.py b/subiquity/palette.py index bcc2e357..0b2dfb4f 100644 --- a/subiquity/palette.py +++ b/subiquity/palette.py @@ -53,6 +53,8 @@ STYLES = [ Palette.black, Palette.dark_green), ('info_minor', '', '', '', Palette.dark_gray, ''), + ('info_error', '', '', '', + Palette.dark_red, ''), ('string_input', '', '', '', Palette.black, Palette.light_gray), ('string_input focus', '', '', '', diff --git a/subiquity/ui/views/identity.py b/subiquity/ui/views/identity.py index e592dee9..5b9c729c 100644 --- a/subiquity/ui/views/identity.py +++ b/subiquity/ui/views/identity.py @@ -36,11 +36,14 @@ class IdentityView(ViewPolicy): self.realname = StringEditor(caption="") self.username = StringEditor(caption="") self.password = PasswordEditor(caption="") + self.error = Text("", align="center") self.confirm_password = PasswordEditor(caption="") body = [ Padding.center_50(self._build_model_inputs()), Padding.line_break(""), + Padding.center_50(Color.info_error(self.error)), + Padding.line_break(""), Padding.center_15(self._build_buttons()), ] super().__init__(ListBox(body)) @@ -97,6 +100,11 @@ class IdentityView(ViewPolicy): return Pile(sl) def done(self, result): + if self.password.value != self.confirm_password.value: + self.error.set_text("Passwords do not match.") + self.password.value = "" + self.confirm_password.value = "" + return cpassword = self.model.encrypt_password(self.password.value) log.debug("*crypted* User input: {} {} {}".format( self.username.value, cpassword, cpassword))