Commit b5350e6e authored by Romain Courteaud's avatar Romain Courteaud

[erp5_hal_json_style] Allow to configure the login and logout action

They should be defined in a local property of the web section
parent 0ed50015
...@@ -94,7 +94,10 @@ url_template_dict = {\n ...@@ -94,7 +94,10 @@ url_template_dict = {\n
"document_hal": "%(root_url)s/%(script_id)s?mode=traverse" + \\\n "document_hal": "%(root_url)s/%(script_id)s?mode=traverse" + \\\n
"&relative_url=%(relative_url)s",\n "&relative_url=%(relative_url)s",\n
"jio_get_template": "urn:jio:get:%(relative_url)s",\n "jio_get_template": "urn:jio:get:%(relative_url)s",\n
"jio_search_template": "urn:jio:allDocs?%(query)s"\n "jio_search_template": "urn:jio:allDocs?%(query)s",\n
# XXX Hardcoded sub websection\n
"login_template": "%(root_url)s/%(login)s",\n
"logout_template": "%(root_url)s/%(logout)s"\n
}\n }\n
\n \n
default_document_uri_template = url_template_dict["jio_get_template"]\n default_document_uri_template = url_template_dict["jio_get_template"]\n
...@@ -656,6 +659,15 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -656,6 +659,15 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
\n \n
\n \n
if (restricted == 1) and (portal.portal_membership.isAnonymousUser()):\n if (restricted == 1) and (portal.portal_membership.isAnonymousUser()):\n
login_relative_url = site_root.getLayoutProperty("configuration_login", default="")\n
if (login_relative_url):\n
response.setHeader(\n
\'WWW-Authenticate\',\n
\'X-Delegate uri="%s"\' % (url_template_dict["login_template"] % {\n
"root_url": site_root.absolute_url(),\n
"login": login_relative_url\n
})\n
)\n
response.setStatus(401)\n response.setStatus(401)\n
\n \n
elif mime_type != traversed_document.Base_handleAcceptHeader([mime_type]):\n elif mime_type != traversed_document.Base_handleAcceptHeader([mime_type]):\n
...@@ -880,6 +892,16 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -880,6 +892,16 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"script_id": script.id\n "script_id": script.id\n
}\n }\n
}\n }\n
elif relative_url == \'acl_users\':\n
logout_relative_url = site_root.getLayoutProperty("configuration_logout", default="")\n
if (logout_relative_url):\n
result_dict[\'_links\'][\'logout\'] = {\n
"href": url_template_dict[\'logout_template\'] % {\n
"root_url": site_root.absolute_url(),\n
"logout": logout_relative_url,\n
"template": True\n
}\n
}\n
\n \n
# Define document action\n # Define document action\n
if action_dict:\n if action_dict:\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_configuration_connection_section</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_viewHateoasPreference</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebSection_viewHateoasPreference</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Web Section Preference</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_configuration_connection_section</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_reference</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Connection Web Section</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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