[rhmessaging-commits] rhmessaging commits: r3754 - mgmt/trunk/cumin/python/cumin/account.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Dec 21 10:12:55 EST 2009


Author: justi9
Date: 2009-12-21 10:12:54 -0500 (Mon, 21 Dec 2009)
New Revision: 3754

Modified:
   mgmt/trunk/cumin/python/cumin/account/widgets.py
Log:
Convert ChangePasswordForm to use FieldSubmitForm; fix an error accessing the login session; consolidate input checks

Modified: mgmt/trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/widgets.py	2009-12-21 14:52:26 UTC (rev 3753)
+++ mgmt/trunk/cumin/python/cumin/account/widgets.py	2009-12-21 15:12:54 UTC (rev 3754)
@@ -148,33 +148,38 @@
         def render_content(self, session):
             return "Submit"
 
-class ChangePasswordForm(CuminFieldForm):
+class ChangePasswordForm(FieldSubmitForm):
     def __init__(self, app, name, task):
         super(ChangePasswordForm, self).__init__(app, name)
 
         self.task = task
 
-        self.__current = self.Current(app, "current")
-        self.add_field(self.__current)
-        self.__current.input.size = 20
+        self.current = self.Current(app, "current")
+        self.current.required = True
+        self.current.input.size = 20
+        self.add_field(self.current)
 
-        self.__new0 = self.New0(app, "new0")
-        self.add_field(self.__new0)
-        self.__new0.input.size = 20
+        self.new0 = self.New0(app, "new0")
+        self.new0.required = True
+        self.new0.input.size = 20
+        self.add_field(self.new0)
 
-        self.__new1 = self.New1(app, "new1")
-        self.add_field(self.__new1)
-        self.__new1.input.size = 20
+        self.new1 = self.New1(app, "new1")
+        self.new1.required = True
+        self.new1.input.size = 20
+        self.add_field(self.new1)
 
-    def process_submit(self, session):
-        curr = self.__current.get(session)
-        new0 = self.__new0.get(session)
-        new1 = self.__new1.get(session)
+    def check(self, session):
+        super(ChangePasswordForm, self).check(session)
 
-        subject = session.user_session.subject
-        crypted = subject.password
+        current = self.current.get(session)
+        new0 = self.new0.get(session)
+        new1 = self.new1.get(session)
 
-        if crypt_password(curr, crypted) != crypted:
+        user = session.client_session.attributes["login_session"].user
+        crypted = user.password
+
+        if crypt_password(current, crypted) != crypted:
             error = FormError("The password is incorrect")
             self.errors.add(session, error)
 
@@ -182,12 +187,16 @@
             error = FormError("The new passwords do not match")
             self.errors.add(session, error)
 
+    def process_submit(self, session):
         self.check(session)
 
         if not self.errors.get(session):
-            self.task.invoke(session, subject, new0)
-            self.task.exit_with_redirect(session, subject)
+            user = session.client_session.attributes["login_session"].user
+            password = self.new0.get(session)
 
+            self.task.invoke(session, user, password)
+            self.task.exit_with_redirect(session, user)
+
     def render_title(self, session):
         return "Change password"
 



More information about the rhmessaging-commits mailing list