acl_users.manage_users and RESPONSE.redirect
I am using the following code (adding to acl_users folder with manage_users) to do user self registration after some initial authentication using Zope authentication and a common login/passwd. It works fine if things are as they should be, but when things go south, password and confirm not equal, login already exists, etc., it isn't so great. I would like to get ahold of the output of manage_users to display on a redirected RESPONSE back to the original vendorRegistration DTML Document. How can I do this? Also, is there a better way to check for a successful user add? Right now I am using, " <dtml-if expr="acl_users.getUser(login)"> ", and that works, but wondered if there was a better way. Help would be much appreciated. I am new to Zope and still trying to get my head around it. thanks, Chris ***** DTML Document - vendorRegistration ****** <dtml-var standard_html_header> <h2><dtml-var title></h2> <p>Register for Vendor Manual distribution</p> <form action="registerAction" method="post" enctype="multipart/form-data"> <table> <tr> <td> Login(e-mail address): </td> <td> <input type="text" name="login"> </td> </tr> <tr> <td> Password: </td> <td> <input type="text" name="password"> </td> </tr> <tr> <td> Confirm Password: </td> <td> <input type="text" name="confirm"> </td> </tr> </table> <input type="submit" value=" Register " > </form> <dtml-var standard_html_footer> ***** DTML Document - registerAction ****** <dtml-var standard_html_header> <h2><dtml-var title></h2> <dtml-call "REQUEST.set('name', login)"> <dtml-call "REQUEST.set('password', password)"> <dtml-call "REQUEST.set('confirm', confirm)"> <dtml-call "REQUEST.set('roles', ['cwcVendor'])"> <dtml-call "REQUEST.set('submit', 'Add')"> <dtml-var expr="acl_users.manage_users(submit='Add', REQUEST=REQUEST )"> <dtml-if expr="acl_users.getUser(login)"> <dtml-var expr="RESPONSE.redirect('Registered')"> <dtml-else> <dtml-var expr="RESPONSE.redirect('vendorRegistration')"> </dtml-if> <dtml-var standard_html_footer>
Chris Jenson wrote:
I am using the following code (adding to acl_users folder with manage_users) to do user self registration after some initial authentication using Zope authentication and a common login/passwd. It works fine if things are as they should be, but when things go south, password and confirm not equal, login already exists, etc., it isn't so great. I would like to get ahold of the output of manage_users to display on a redirected RESPONSE back to the original vendorRegistration DTML Document. How can I do this?
Might I suggest not letting yourself get into those situations? Check the acl_users folder for a matching id (login) and test the password for matches before you try to commit them. You'll throw an exception and the user will be required to press the back button and fix it. *** UNTESTED *** <dtml-in acl_users> <dtml-if login==sequence-item> <dtml-raise ID_Error>Login Already In Use.</dtml-raise> </dtml-if> </dtml-in> <dtml-unless "pat_password==pat_password2"> <dtml-raise PasswordError>Passwords Do Not Match.</dtml-raise> </dtml-unless> ...
<dtml-var standard_html_header> <h2><dtml-var title></h2>
<dtml-call "REQUEST.set('name', login)"> <dtml-call "REQUEST.set('password', password)"> ...
HTH, -- Tim Cook -- Cook Information Systems | Office: (901) 884-4126 8am-5pm CDT * Specializing in Open Source Business Systems * FreePM Project Coordinator http://www.freepm.org OSHCA Founding Supporter http://www.oshca.org
Tim Cook wrote:
Chris Jenson wrote:
I am using the following code (adding to acl_users folder with manage_users) to do user self registration after some initial authentication using Zope authentication and a common login/passwd. It works fine if things are as they should be, but when things go south, password and confirm not equal, login already exists, etc., it isn't so great. I would like to get ahold of the output of manage_users to display on a redirected RESPONSE back to the original vendorRegistration DTML Document. How can I do this?
Might I suggest not letting yourself get into those situations?
Check the acl_users folder for a matching id (login) and test the password for matches before you try to commit them. You'll throw an exception and the user will be required to press the back button and fix it.
*** UNTESTED *** <dtml-in acl_users> <dtml-if login==sequence-item> <dtml-raise ID_Error>Login Already In Use.</dtml-raise> </dtml-if> </dtml-in>
<dtml-unless "pat_password==pat_password2"> <dtml-raise PasswordError>Passwords Do Not Match.</dtml-raise>
OOOPS! Can you tell I copied that right out of some other code? <s> To match your code it should be: <dtml-unless "password==confirm"> <dtml-raise PasswordError>Passwords Do Not Match.</dtml-raise> ... -- Tim Cook -- Cook Information Systems | Office: (901) 884-4126 8am-5pm CDT * Specializing in Open Source Business Systems * FreePM Project Coordinator http://www.freepm.org OSHCA Founding Supporter http://www.oshca.org
participants (2)
-
Chris Jenson -
Tim Cook