Commit b3fa0428 authored by Vincent Pelletier's avatar Vincent Pelletier

erp5_xhtml_style: Fix logged_in handling of came_from when authentication failed.

Also, modernise it a bit.
parent d98bb397
......@@ -4,14 +4,23 @@ if portal.portal_skins.updateSkinCookie():
url = REQUEST.get("came_from")
if portal.portal_membership.isAnonymousUser():
RESPONSE.expireCookie("__ac", path="/")
url = "%s/login_form?portal_status_message=%s" % (
context.absolute_url(),
context.Base_translateString("Login and/or password is incorrect.")
+ ("&came_from=" + url if url else ""))
elif not url:
keep_item_dict = {
'portal_status_message': context.Base_translateString("Login and/or password is incorrect."),
}
if url:
keep_item_dict['came_from'] = url
context.Base_redirect(
form_id='login_form',
keep_items=keep_item_dict,
)
return
if not url:
url = context.absolute_url()
topmost_url_document = context.Base_getURLTopmostDocumentValue()
if not topmost_url_document.isURLAncestorOf(url):
return context.ERP5Site_redirect(topmost_url_document.absolute_url(),
keep_items={'portal_status_message': 'Redirection to an external site prevented.'})
return topmost_url_document.Base_redirect(
keep_items={
'portal_status_message': context.Base_translateString('Redirection to an external site prevented.'),
}
)
return RESPONSE.redirect(url)
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