Re: Plone Benutzer mit Skript automatisch einloggen

Carsten Senger <[email protected]>
Newsgroups gmane.comp.web.zope.german
Message-ID <6F3B5B326D3235C1B0F2728C@[192.168.178.20]>
Hallo Nico,

--On Freitag, Dezember 04, 2009 10:30:29 +0100 Nico Grubert
<[email protected]> wrote:

> Hallo zusammen
>
> Ich versuche, einen Benutzer der seinen Benutzernamen und Passwort
> eingibt, in Plone automatisch einzuloggen.
> Use-Case:
> Es sollen noch weitere Bedingungen geprüft werden (z.B. ob der Benutzer
> einen publizierten speziellen Ordner mit seiner Id hat) bevor der
> Benutzer in Plone eingeloggt ist.

das läuft mit einem standard Plone 3.1:

..Carsten

## Script (Python) "pwreset_action.cpy"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##title=Reset a user's password
##parameters=randomstring, userid=None, password=None, password2=None
from Products.CMFCore.utils import getToolByName

status = "success"
pw_tool = getToolByName(context, 'portal_password_reset')
try:
    pw_tool.resetPassword(userid, randomstring, password)
except 'ExpiredRequestError':
    status = "expired"
except 'InvalidRequestError':
    status = "invalid"
else:
    REQUEST = context.REQUEST
    RESPONSE = REQUEST.RESPONSE
    portal = context.portal_url.getPortalObject()
    REQUEST.set('__ac_name', userid)
    REQUEST.set('__ac_password', password)
    auth = context.acl_users.credentials_cookie_auth
    auth.login()
    RESPONSE.redirect(context.portal_url())
    #auth.updateCredentials(REQUEST, RESPONSE, userid, password)



return state.set(status=status)



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.