[Freeipa-devel] [PATCH] confirm password

Kevin McCarthy kmccarth at redhat.com
Thu Sep 6 21:27:19 UTC 2007


After some feedback from Bob and Pete, I'm removing the password
generator and adding a confirm password field.  (Just commented out for
now in case people change their mind)

Factored out the validators.

Minor css tweaks.

This is a small fix, but I have to rebuild my dev environment and wanted
to get it to the list before then.

-Kevin
-------------- next part --------------
# HG changeset patch
# User Kevin McCarthy <kmccarth at redhat.com>
# Date 1189114101 25200
# Node ID 9ec22fc089922c9479ce5b9d523313965a8d576a
# Parent  b401723077f1f3e705f983185b07c47a95eb2579
Password changes:
  - remove password generator button
  - add confirm password field

diff -r b401723077f1 -r 9ec22fc08992 ipa-server/ipa-gui/ipagui/controllers.py
--- a/ipa-server/ipa-gui/ipagui/controllers.py	Thu Sep 06 11:09:12 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/controllers.py	Thu Sep 06 14:28:21 2007 -0700
@@ -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 -r b401723077f1 -r 9ec22fc08992 ipa-server/ipa-gui/ipagui/forms/user.py
--- a/ipa-server/ipa-gui/ipagui/forms/user.py	Thu Sep 06 11:09:12 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/forms/user.py	Thu Sep 06 14:28:21 2007 -0700
@@ -3,7 +3,9 @@ from turbogears import validators, widge
 
 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']
@@ -37,6 +45,8 @@ class UserNewForm(widgets.Form):
     fields = [UserFields.uid, UserFields.givenname,
               UserFields.uidnumber, UserFields.gidnumber,
               UserFields.sn, UserFields.mail]
+
+    validator = UserNewValidator()
 
     def __init__(self, *args, **kw):
         super(UserNewForm,self).__init__(*args, **kw)
@@ -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']
@@ -59,6 +81,8 @@ class UserEditForm(widgets.Form):
               UserFields.uidnumber_hidden, UserFields.gidnumber_hidden,
               UserFields.krbPasswordExpiration_hidden,
               ]
+
+    validator = UserEditValidator()
 
     def __init__(self, *args, **kw):
         super(UserEditForm,self).__init__(*args, **kw)
diff -r b401723077f1 -r 9ec22fc08992 ipa-server/ipa-gui/ipagui/static/css/style.css
--- a/ipa-server/ipa-gui/ipagui/static/css/style.css	Thu Sep 06 11:09:12 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/static/css/style.css	Thu Sep 06 14:28:21 2007 -0700
@@ -31,6 +31,7 @@ body {
 
 #header #headerinfo {
   text-align:right;
+  padding-right:10px;
 }
 
 #header #headerinfo #login {
diff -r b401723077f1 -r 9ec22fc08992 ipa-server/ipa-gui/ipagui/templates/usereditform.kid
--- a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid	Thu Sep 06 11:09:12 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid	Thu Sep 06 14:28:21 2007 -0700
@@ -56,8 +56,9 @@
           <span py:replace="user.userpassword.display(value_for(user.userpassword))" />
           <span py:if="tg.errors.get('userpassword')" class="fielderror"
               py:content="tg.errors.get('userpassword')" />
+
+          <!-- 
           <span id="password_text">********</span>
-
           <input id="genpassword_button" type="button" value="Generate Password"
               disabled="true"
               onclick="new Ajax.Request('${tg.url('/generate_password')}',
@@ -89,6 +90,20 @@
               }
             }
           </script>
+          -->
+        </td>
+      </tr>
+
+      <tr>
+        <th valign="top">
+          <label class="fieldlabel" for="${user.userpassword_confirm.field_id}"
+            py:content="user.userpassword_confirm.label" />:
+        </th>
+        <td valign="top">
+          <span py:replace="user.userpassword_confirm.display(
+               value_for(user.userpassword_confirm))" />
+          <span py:if="tg.errors.get('userpassword_confirm')" class="fielderror"
+              py:content="tg.errors.get('userpassword_confirm')" />
         </td>
       </tr>
 
diff -r b401723077f1 -r 9ec22fc08992 ipa-server/ipa-gui/ipagui/templates/usernewform.kid
--- a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid	Thu Sep 06 11:09:12 2007 -0700
+++ b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid	Thu Sep 06 14:28:21 2007 -0700
@@ -92,6 +92,7 @@
           <span py:if="tg.errors.get('userpassword')" class="fielderror"
               py:content="tg.errors.get('userpassword')" />
 
+          <!--
           <input type="button" value="Generate Password"
               onclick="new Ajax.Request('${tg.url('/generate_password')}',
                 {
@@ -101,6 +102,20 @@
                         transport.responseText;
                   }
                 });" />
+            -->
+        </td>
+      </tr>
+
+      <tr>
+        <th>
+          <label class="fieldlabel" for="${user.userpassword_confirm.field_id}"
+            py:content="user.userpassword_confirm.label" />:
+        </th>
+        <td>
+          <span py:replace="user.userpassword_confirm.display(
+              value_for(user.userpassword_confirm))" />
+          <span py:if="tg.errors.get('userpassword_confirm')" class="fielderror"
+              py:content="tg.errors.get('userpassword_confirm')" />
         </td>
       </tr>
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2228 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20070906/05272cda/attachment.bin>


More information about the Freeipa-devel mailing list