[Zope] Logging in a user programatically...

seb bacon seb@jamkit.com
Sun, 4 Nov 2001 01:56:41 +0000


* Rob Foster <rob@thefosters.com> [011104 00:22]:
> I've got a form that allows a new user to create a login for themselves 
> in the acl_users folder. I want to be able to immediately log them into 
> the system when their account is created (possibly in the same script). 

Yes, I used to ask this question a lot and never got an answer.  I
gave up and then worked it out about 18 months later :-)  Here's how you
can do it from a python Product:

    from AccessControl.SecurityManagement import newSecurityManager
    ...
    newSecurityManager(None, user)

(where 'user' is the new user object you just created).

You couldn't do this in a pythonscript or dtml without creating a
fairly massive security hole, though.  You'd be able to do it with an
external method, but you'd want to make sure only the person who's
creating the account can call it.

seb