A simple way: customize logged_out
, transform it to a Python Script that redirect to whatever page you want:
context.REQUEST.RESPONSE.redirect(url)
You can also raise a Redirect exception in your event handler
from zExceptions import Redirect def goCameFromAfterLogout(event): "" " Redirects user to came_from url parameter after logout "" " request = event.object.REQUEST came_from = request.form.get('came_from', None) if came_from: raise Redirect(came_from)
You can use the collective.onlogin package to set up many actions for you.,Login as another user (“sudo”) Getting logged in users Locking user account after too many retries Hyperlinks to authenticated Plone content in Microsoft Office ,Post-login actions are executed after a successful login. Post-login actions which you could want to change are,For security reasons, you might want to locking users after too many tries of logins. This protects user accounts against brute force attacks.
def extract_credentials(self, login, password): "" " Spoof HTTP login attempt. Functional test using zope.testbrowser would be more appropriate way to test this. "" " request = self.portal.REQUEST # Assume publishing process has succeeded and object has been found by traversing #(this is usually set by ZPublisher) request['PUBLISHED'] = self.portal # More ugly ZPublisher stubs request['PARENTS'] = [self.portal] request.steps = [self.portal] # Spoof HTTP request login fields request["__ac_name"] = login request["__ac_password"] = password # Call PluggableAuthService._extractUserIds() # which will return a list of user ids extracted from the request plugins = self.portal.acl_users.plugins users = self.portal.acl_users._extractUserIds(request, plugins) if len(users) == 0: return None self.assertEqual(len(users), 1) # User will be none if the authentication fails # or anonymous if there were no credential fields in HTTP request return users[0]
def authenticate_using_credentials(self, login, password):
request = self.portal.REQUEST
# Will
return valid user object
user = self.portal.acl_users.authenticate(login, password, request)
self.assertNotEqual(user, None)
def loginUser(self, username): "" " Login Plone user(without password) "" " self.context.acl_users.session._setupSession(username, self.context.REQUEST.RESPONSE) self.request.RESPONSE.redirect(self.portal_state.portal_url())
<configure xmlns="http://namespaces.zope.org/zope" i18n_domain="my.package">
<subscriber for="Products.PluggableAuthService.interfaces.events.IUserLoggedInEvent" handler=".postlogin.logged_in_handler" />
</configure>
<subscriber for="Products.PlonePAS.events.UserLoggedOutEvent" handler=".smartcard.clear_extra_cookies_on_logout" />
The easy way: customize logged_out , convert it to Python Script that redirects to whatever page you want:,The event is ok, the come_from parameter is ok, but the code doesn't work as I want. The website redirects me /logged_out every time.,You can also create a redirect exception in your event handler,I want to set up a plone site to redirect to the came_from parameter in the url after the user logs out. For login, I installed string:${globals_view/navigationRootUrl}/login?came_from=${context/absolute_url} and it works.
It doesn't work for logging out. I also tried with my event:
<subscriber
for="Products.PlonePAS.events.UserLoggedOutEvent"
handler="blabla.goCameFromAfterLogout"
/>
(adsbygoogle = window.adsbygoogle || []).push({});
through:
def goCameFromAfterLogout(event): "" " Redirects user to came_from url parameter after logout "" " import pdb; pdb.set_trace() request = event.object.REQUEST came_from = request.form.get('came_from', None) if came_from: response = request.RESPONSE response.redirect(came_from) (adsbygoogle = window.adsbygoogle || []).push({});
context.REQUEST.RESPONSE.redirect(url)
(adsbygoogle = window.adsbygoogle || []).push({});
from zExceptions import Redirect def goCameFromAfterLogout(event): "" " Redirects user to came_from url parameter after logout "" " request = event.object.REQUEST came_from = request.form.get('came_from', None) if came_from: raise Redirect(came_from) (adsbygoogle = window.adsbygoogle || []).push({});
To install plone.app.discussion, add the following code to your buildout.cfg:,No more recursive came_from redirection after logged_in. [kcleong, huubbouma],Make sure you pin down plone.app.discussion to versions < 2.0 if you want to install it as an add-on product (see install instructions below for more details).,ImportError: No module named owner: You are trying to install plone.app.discussion 2.x on Plone < 4.1. Pin plone.app.discussion to a version < 2.0.
To install plone.app.discussion, add the following code to your buildout.cfg:
[buildout]
...
extends =
...
http: //good-py.appspot.com/release/plone.app.discussion/1.0
...
[versions]
plone.app.discussion = 1.0
...
[instance]
...
eggs =
...
plone.app.discussion
...
To install plone.app.discussion, add the following code to your buildout.cfg:
[buildout] ... versions = versions [versions] plone.app.discussion = 1.0 zope.schema = 3.6 .4 ... [instance] ... eggs = ... plone.app.discussion ...