From 2ef4792fd12efc84237e005add0ed0081425d599 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 14 Aug 2007 09:40:13 -0700 Subject: - Add password generator method to controller. This uses the random.SystemRandom() method to generate an 8-digit alphanumeric password. - Add ajax call to usernew and useredit forms to generate a new password - Add the prototype javascript library: http://www.prototypejs.org/ prototype is distributed with the MIT license. - Add a checkbox to toggle editing (and displaying) the password. - Change usershow template to use same field labels as the edit and new forms. --- ipa-server/ipa-gui/ipagui/controllers.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'ipa-server/ipa-gui/ipagui/controllers.py') diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py index ec4b8719..acf1bd37 100644 --- a/ipa-server/ipa-gui/ipagui/controllers.py +++ b/ipa-server/ipa-gui/ipagui/controllers.py @@ -1,3 +1,4 @@ +import random import cherrypy import turbogears from turbogears import controllers, expose, flash @@ -17,6 +18,8 @@ ipa.config.init_config() user_new_form = forms.user.UserNewForm() user_edit_form = forms.user.UserEditForm() +password_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + client = ipa.ipaclient.IPAClient(True) client.set_principal("test@FREEIPA.ORG") @@ -137,7 +140,7 @@ class Root(controllers.RootController): """Retrieve a single user for display""" try: user = client.get_user(uid) - return dict(user=user_to_hash(user)) + return dict(user=user_to_hash(user), fields=forms.user.UserFields()) except xmlrpclib.Fault, f: turbogears.flash("User show failed: " + str(f.faultString)) raise turbogears.redirect("/") @@ -154,6 +157,16 @@ class Root(controllers.RootController): def userindex(self): raise turbogears.redirect("/userlist") + @expose() + def generate_password(self): + password = "" + generator = random.SystemRandom() + for char in range(8): + index = generator.randint(0, len(password_chars) - 1) + password += password_chars[index] + + return password + ######### # Group # -- cgit