Commit 3e36d70a authored by Rafael Monnerat's avatar Rafael Monnerat

Fix "Go back' on login

See merge request !1616
parents 628ab4b4 3ffd3418
Pipeline #21292 failed with stage
in 0 seconds
import re
from ZTUtils import make_query
portal = context.getPortalObject()
# XXX Hardcoded behaviour for JS app.
# Expect came_from to be an URL template
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
url_parameter = "n.me"
pattern = '{[&|?]%s}' % url_parameter
if (person is None or not portal.portal_membership.checkPermission('View', person)):
came_from = re.sub(pattern, '', came_from)
else:
prefix = "&" if "&%s" % url_parameter in came_from else "?"
came_from = re.sub(pattern, '%s%s' % (prefix, make_query({url_parameter: person.getRelativeUrl()})), came_from)
return came_from
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>came_from</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_renderCameFromURITemplate</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import re
REQUEST = context.REQUEST REQUEST = context.REQUEST
RESPONSE = REQUEST.RESPONSE RESPONSE = REQUEST.RESPONSE
from ZTUtils import make_query from ZTUtils import make_query
...@@ -35,16 +34,7 @@ else: ...@@ -35,16 +34,7 @@ else:
# XXX How to warn user that password will expire? # XXX How to warn user that password will expire?
# is_user_account_password_expired_expire_date = REQUEST.get('is_user_account_password_expired_expire_date', 0) # is_user_account_password_expired_expire_date = REQUEST.get('is_user_account_password_expired_expire_date', 0)
# XXX Hardcoded behaviour for JS app. came_from = context.WebSection_renderCameFromURITemplate(came_from)
# Expect came_from to be an URL template
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
url_parameter = "n.me"
pattern = '{[&|?]%s}' % url_parameter
if (person is None or not portal.portal_membership.checkPermission('View', person)):
came_from = re.sub(pattern, '', came_from)
else:
prefix = "&" if "&%s" % url_parameter in came_from else "?"
came_from = re.sub(pattern, '%s%s' % (prefix, make_query({url_parameter: person.getRelativeUrl()})), came_from)
# RESPONSE.redirect(came_from or context.getPermanentURL(context)); # RESPONSE.redirect(came_from or context.getPermanentURL(context));
RESPONSE.setHeader('Location', came_from or context.getPermanentURL(context)) RESPONSE.setHeader('Location', came_from or context.getPermanentURL(context))
RESPONSE.setStatus(303) RESPONSE.setStatus(303)
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<section tal:condition="not: portal/portal_membership/isAnonymousUser"> <section tal:condition="not: portal/portal_membership/isAnonymousUser">
<p i18n:domain="ui" i18n:translate="" >It seems you're already authenticated.</p> <p i18n:domain="ui" i18n:translate="" >It seems you're already authenticated.</p>
<p><a tal:condition="exists: request/came_from" <p><a tal:condition="exists: request/came_from"
tal:attributes="href request/came_from" >Go back</a></p> tal:attributes="href python:context.WebSection_renderCameFromURITemplate(request.came_from)" >Go back</a></p>
</section> </section>
<section tal:condition="portal/portal_membership/isAnonymousUser"> <section tal:condition="portal/portal_membership/isAnonymousUser">
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
<a tal:attributes="href string:${current_url}/ERP5Site_redirectToFacebookLoginPage" <a tal:attributes="href string:${current_url}/ERP5Site_redirectToFacebookLoginPage"
i18n:translate="" i18n:translate=""
i18n:domain="ui" i18n:domain="ui"
class="sign_in_with_facebook"
> >
<img alt="Login with Facebook" src="facebook_login_button.png"> <img alt="Login with Facebook" src="facebook_login_button.png">
</a> </a>
...@@ -90,6 +92,8 @@ ...@@ -90,6 +92,8 @@
<a tal:attributes="href string:${current_url}/ERP5Site_redirectToOpenIdLoginPage" <a tal:attributes="href string:${current_url}/ERP5Site_redirectToOpenIdLoginPage"
i18n:translate="" i18n:translate=""
i18n:domain="ui" i18n:domain="ui"
class="sign_in_with_openid"
> >
<img alt="Sign in with OpenID Connect" src="openid_login_button.png"/> <img alt="Sign in with OpenID Connect" src="openid_login_button.png"/>
......
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