Question

I have a custom registration BrowserView where you have to extend some userdata (z3c.form with some fields including password). after successful saving these data i want the user to be logged in automaticaly and redirected to an other page in the site.

Thanks in advance for hints

Was it helpful?

Solution

So here's my working solution (thanks to mikko who pointed in the right direction):

  1. authenticate your registration credentials in PAS

    member = portal.acl_users.authenticate(username, password, portal.REQUEST)
    
  2. for redirects it's neccessary to set the authentication cookie. You can do this with "updateCredentials" (see pas/plugins/cookie_handler)

    if member:
        portal.acl_users.updateCredentials(portal.REQUEST, portal.REQUEST.RESPONSE, username, password)
    
  3. redirect to the next page

    portal.REQUEST.RESPONSE.redirect(url)
    

OTHER TIPS

If you want to extend the userdata for new members, and add new fields to the registration form, it's probably best to extend the utility that provides the default userdata schema and to do it in such a way that you seamlessly hook into the existing registration machinery.

There is an example product collective.examples.userdata which you can use0 and extend for this purpose. It also has good documentation that explains to you all the necessary steps.

http://plone.org/products/collective.examples.userdata

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top