Commit ef35e421 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_core: ERP5 Auto Logout use PAS to set and revoke credential

parent 5eb36066
......@@ -8,5 +8,5 @@ portal.portal_sessions.manage_delObjects(
REQUEST = portal.REQUEST
if REQUEST.has_key('portal_skin'):
portal.portal_skins.clearSkinCookie()
REQUEST.RESPONSE.expireCookie('__ac', path='/')
portal.acl_users.logout(REQUEST)
return REQUEST.RESPONSE.redirect(REQUEST.URL1 + '/logged_out')
from base64 import standard_b64encode, standard_b64decode
if cookie_value is not None and login is None:
from urllib import unquote
login, password = unquote(cookie_value).decode('base64').split(':', 1)
portal = context.getPortalObject()
kw = {}
expire_interval = portal.portal_preferences.getPreferredMaxUserInactivityDuration()
if expire_interval in ('', None):
ac_renew = float('inf')
else:
expire_interval /= 86400. # seconds -> days
now = DateTime()
kw['expires'] = (now + expire_interval).toZone('GMT').rfc822()
ac_renew = (now + expire_interval / 2).millis()
portal.portal_sessions[
portal.Base_getAutoLogoutSessionKey(
username=portal.Base_getUsernameFromAuthenticationCookie(
cookie_value,
)
)
]['ac_renew'] = ac_renew
resp.setCookie(
name=cookie_name,
value=cookie_value,
path='/',
secure=getattr(portal, 'REQUEST', {}).get('SERVER_URL', '').startswith('https:'),
http_only=True,
**kw
)
portal.acl_users.updateCredentials(context.REQUEST, resp, login, password)
......@@ -170,7 +170,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>resp, cookie_name, cookie_value</string> </value>
<value> <string>resp, cookie_name, cookie_value=None, login=None, password=None </string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment