Merge pull request #50 from CanonicalLtd/patch-password-validate

Add password match validator
This commit is contained in:
Adam Stokes 2015-09-28 11:05:55 -04:00
commit a4f8bc9cf4
2 changed files with 10 additions and 0 deletions

View File

@ -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', '', '', '',

View File

@ -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))