From c821699b64cba075506ecafb187c36eaf866248d Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Thu, 6 Sep 2007 14:28:21 -0700 Subject: Password changes: - remove password generator button - add confirm password field --- ipa-server/ipa-gui/ipagui/controllers.py | 2 +- ipa-server/ipa-gui/ipagui/forms/user.py | 42 +++++++++++++++++----- ipa-server/ipa-gui/ipagui/static/css/style.css | 1 + .../ipa-gui/ipagui/templates/usereditform.kid | 17 ++++++++- .../ipa-gui/ipagui/templates/usernewform.kid | 15 ++++++++ 5 files changed, 66 insertions(+), 11 deletions(-) (limited to 'ipa-server') diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py index b984c2a05..538e66b40 100644 --- a/ipa-server/ipa-gui/ipagui/controllers.py +++ b/ipa-server/ipa-gui/ipagui/controllers.py @@ -197,7 +197,7 @@ class Root(controllers.RootController): def userindex(self): raise turbogears.redirect("/userlist") - @expose() + # @expose() def generate_password(self): password = "" generator = random.SystemRandom() diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py index 859b3023d..334e61379 100644 --- a/ipa-server/ipa-gui/ipagui/forms/user.py +++ b/ipa-server/ipa-gui/ipagui/forms/user.py @@ -3,7 +3,9 @@ from turbogears import validators, widgets class UserFields(): uid = widgets.TextField(name="uid", label="Login") - userpassword = widgets.TextField(name="userpassword", label="Password") + userpassword = widgets.PasswordField(name="userpassword", label="Password") + userpassword_confirm = widgets.PasswordField(name="userpassword_confirm", + label="Confirm Password") uidnumber = widgets.TextField(name="uidnumber", label="UID") gidnumber = widgets.TextField(name="gidnumber", label="GID") givenname = widgets.TextField(name="givenname", label="First name") @@ -15,14 +17,6 @@ class UserFields(): label="Account Status", options = [("", "active"), ("true", "inactive")]) - uid.validator = validators.PlainText(not_empty=True) - userpassword.validator = validators.String(not_empty=True) - givenname.validator = validators.String(not_empty=True) - sn.validator = validators.String(not_empty=True) - mail.validator = validators.Email(not_empty=True) - # validators.PhoneNumber may be a bit too picky, requiring an area code - telephonenumber.validator = validators.PlainText(not_empty=True) - uid_hidden = widgets.HiddenField(name="uid") uidnumber_hidden = widgets.HiddenField(name="uidnumber") gidnumber_hidden = widgets.HiddenField(name="gidnumber") @@ -30,6 +24,20 @@ class UserFields(): user_orig = widgets.HiddenField(name="user_orig") +class UserNewValidator(validators.Schema): + uid = validators.PlainText(not_empty=True) + userpassword = validators.String(not_empty=True) + userpassword_confirm = validators.String(not_empty=True) + givenname = validators.String(not_empty=True) + sn = validators.String(not_empty=True) + mail = validators.Email(not_empty=True) + # validators.PhoneNumber may be a bit too picky, requiring an area code + # telephonenumber = validators.PlainText(not_empty=False) + + chained_validators = [ + validators.FieldsMatch('userpassword', 'userpassword_confirm') + ] + class UserNewForm(widgets.Form): params = ['user'] @@ -38,6 +46,8 @@ class UserNewForm(widgets.Form): UserFields.uidnumber, UserFields.gidnumber, UserFields.sn, UserFields.mail] + validator = UserNewValidator() + def __init__(self, *args, **kw): super(UserNewForm,self).__init__(*args, **kw) (self.template_c, self.template) = widgets.meta.load_kid_template("ipagui.templates.usernewform") @@ -50,6 +60,18 @@ class UserNewForm(widgets.Form): def has_foo(self): return False +class UserEditValidator(validators.Schema): + userpassword = validators.String(not_empty=False) + userpassword_confirm = validators.String(not_empty=False) + givenname = validators.String(not_empty=True) + sn = validators.String(not_empty=True) + mail = validators.Email(not_empty=True) + # validators.PhoneNumber may be a bit too picky, requiring an area code + # telephonenumber = validators.PlainText(not_empty=False) + + chained_validators = [ + validators.FieldsMatch('userpassword', 'userpassword_confirm') + ] class UserEditForm(widgets.Form): params = ['user'] @@ -60,6 +82,8 @@ class UserEditForm(widgets.Form): UserFields.krbPasswordExpiration_hidden, ] + validator = UserEditValidator() + def __init__(self, *args, **kw): super(UserEditForm,self).__init__(*args, **kw) (self.template_c, self.template) = widgets.meta.load_kid_template("ipagui.templates.usereditform") diff --git a/ipa-server/ipa-gui/ipagui/static/css/style.css b/ipa-server/ipa-gui/ipagui/static/css/style.css index 5a38f3409..9654ebf15 100644 --- a/ipa-server/ipa-gui/ipagui/static/css/style.css +++ b/ipa-server/ipa-gui/ipagui/static/css/style.css @@ -31,6 +31,7 @@ body { #header #headerinfo { text-align:right; + padding-right:10px; } #header #headerinfo #login { diff --git a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid index 4d4269b87..6227c4440 100644 --- a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid +++ b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid @@ -56,8 +56,9 @@ - ******** + + + + + + +