Commit 4b2f3583 authored by Boxiang Sun's avatar Boxiang Sun Committed by Rafael Monnerat

slapos_jio: Notify user they are trying to access document without correct permission

And display a "logout" button in the page.
Instead display plain renderjs error message
parent 38b047d5
<!DOCTYPE html>
<html>
<!--
data-i18n=User
data-i18n=Language
data-i18n=Update
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Page Language</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script id="dialog-button-template" type="text/x-handlebars-template">
<input name="action_update" type="submit" value="{{button_text}}"></input>
</script>
<script src="gadget_erp5_page_slap_access_denied_view.js" type="text/javascript"></script>
</head>
<body>
<form>
<button type="submit" class="ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="erp5_form"
data-gadget-sandbox="public">
</div>
<input type="submit" />
</form>
</body>
</html>
/*global window, rJS, RSVP, Handlebars, UriTemplate */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, UriTemplate) {
"use strict";
var gadget_klass = rJS(window),
dialog_button_source = gadget_klass.__template_element
.getElementById("dialog-button-template")
.innerHTML,
dialog_button_template = Handlebars.compile(dialog_button_source);
gadget_klass
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getUrlForList([{command: 'display'}]),
gadget.getDeclaredGadget("erp5_form"),
gadget.translate("You are not allowed to access this content, please login with an user which has the right permission")
]);
})
.push(function (result_list) {
var user,
key,
list_item = [];
return RSVP.all([
gadget.updateHeader({
page_title: 'Error page',
front_url: result_list[0][0]
}),
result_list[1].render({
erp5_document: {"_embedded": {"_view": {
'Message': {
"default": result_list[2],
"editable": 0,
"key": "field_message",
"title": "",
"type": "StringField"
}
}},
"_links": {
"type": {
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["Message"]]
]]
}
})
]);
})
.push(function () {
return gadget.translate('Logout');
})
.push(function (translated_text) {
gadget.element.querySelector('input').value = translated_text;
});
})
.onEvent('submit', function () {
var gadget = this,
logout_url_template;
return gadget.jio_getAttachment('acl_users', 'links')
.push(function (links) {
logout_url_template = links._links.logout.href;
return gadget.getUrlFor({
command: 'display',
absolute_url: true,
options: {}
});
})
.push(function (came_from) {
return gadget.redirect({
command: 'raw',
options: {
url: UriTemplate.parse(logout_url_template).expand({came_from: came_from})
}
});
});
})
.declareMethod("triggerSubmit", function () {
return;
});
}(window, rJS, RSVP, Handlebars, UriTemplate));
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_controller.js" type="text/javascript"></script> <script src="gadget_erp5_page_slap_controller.js" type="text/javascript"></script>
</head> </head>
......
...@@ -202,6 +202,7 @@ ...@@ -202,6 +202,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
...@@ -234,7 +235,7 @@ ...@@ -234,7 +235,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.57488.48170.50312</string> </value> <value> <string>980.6873.14525.36027</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +253,7 @@ ...@@ -252,7 +253,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1508424107.98</float> <float>1576490697.25</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -261,6 +262,7 @@ ...@@ -261,6 +262,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
...@@ -318,6 +320,7 @@ ...@@ -318,6 +320,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
var gadget = this, var gadget = this,
child_gadget_url; child_gadget_url;
return gadget.jio_get(options.jio_key) return window.getValidDocument(gadget, options.jio_key)
.push(function (result) { .push(function (result) {
if (result.portal_type === "Support Request Module") { if (result.portal_type === "Support Request Module") {
...@@ -77,6 +77,12 @@ ...@@ -77,6 +77,12 @@
throw new Error('Can not display document: ' + options.jio_key); throw new Error('Can not display document: ' + options.jio_key);
} }
if (child_gadget_url === 'gadget_erp5_page_slap_access_denied_view.html') {
// if user try to access a document without correct permission
// user will be redirected to this page, in this case, set the jio_key
// to null to avoid some further processing.
options.jio_key = null;
}
return gadget.changeState({ return gadget.changeState({
jio_key: options.jio_key, jio_key: options.jio_key,
doc: result, doc: result,
......
...@@ -198,6 +198,7 @@ ...@@ -198,6 +198,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
...@@ -230,7 +231,7 @@ ...@@ -230,7 +231,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>978.36745.20465.19319</string> </value> <value> <string>980.35642.57629.14574</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +249,7 @@ ...@@ -248,7 +249,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1568971515.61</float> <float>1576597179.41</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -257,6 +258,7 @@ ...@@ -257,6 +258,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
...@@ -314,6 +316,7 @@ ...@@ -314,6 +316,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
</div> </div>
</script> </script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_slapos_panel.js" type="text/javascript"></script> <script src="gadget_slapos_panel.js" type="text/javascript"></script>
</head> </head>
......
...@@ -202,6 +202,7 @@ ...@@ -202,6 +202,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
...@@ -234,7 +235,7 @@ ...@@ -234,7 +235,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.61786.203.13243</string> </value> <value> <string>980.6873.14525.36027</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +253,7 @@ ...@@ -252,7 +253,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1554918794.64</float> <float>1576494063.72</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -261,6 +262,7 @@ ...@@ -261,6 +262,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
...@@ -318,6 +320,7 @@ ...@@ -318,6 +320,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
......
...@@ -41,4 +41,13 @@ ...@@ -41,4 +41,13 @@
return redirectToLoginPage(gadget); return redirectToLoginPage(gadget);
}); });
}; };
window.getValidDocument = function getValidDocument(gadget, jio_key) {
return new RSVP.Queue()
.push(function () {
return gadget.jio_get(jio_key);
})
.push(undefined, function (error) {
return {"portal_type": "access_denied"};
});
};
}(window, RSVP, UriTemplate)); }(window, RSVP, UriTemplate));
\ No newline at end of file
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>980.28540.27588.10854</string> </value> <value> <string>980.35650.56461.57958</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1576170214.7</float> <float>1576597139.51</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -61,6 +61,8 @@ web_page_module/rjs_gadget_erp5_page_slap_google_login_view_html ...@@ -61,6 +61,8 @@ web_page_module/rjs_gadget_erp5_page_slap_google_login_view_html
web_page_module/rjs_gadget_erp5_page_slap_google_login_view_js web_page_module/rjs_gadget_erp5_page_slap_google_login_view_js
web_page_module/rjs_gadget_erp5_page_slap_hosting_subscription_view_html web_page_module/rjs_gadget_erp5_page_slap_hosting_subscription_view_html
web_page_module/rjs_gadget_erp5_page_slap_hosting_subscription_view_js web_page_module/rjs_gadget_erp5_page_slap_hosting_subscription_view_js
web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_html
web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_js
web_page_module/rjs_gadget_erp5_page_slap_intent_html web_page_module/rjs_gadget_erp5_page_slap_intent_html
web_page_module/rjs_gadget_erp5_page_slap_intent_js web_page_module/rjs_gadget_erp5_page_slap_intent_js
web_page_module/rjs_gadget_erp5_page_slap_invalidate_login_html web_page_module/rjs_gadget_erp5_page_slap_invalidate_login_html
......
...@@ -9,6 +9,8 @@ web_page_module/rjs_gadget_erp5_page_map_html ...@@ -9,6 +9,8 @@ web_page_module/rjs_gadget_erp5_page_map_html
web_page_module/rjs_gadget_erp5_page_map_js web_page_module/rjs_gadget_erp5_page_map_js
web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_html web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_html
web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_js web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_js
web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_html
web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_js
web_page_module/rjs_gadget_erp5_page_slap_add_computer_html web_page_module/rjs_gadget_erp5_page_slap_add_computer_html
web_page_module/rjs_gadget_erp5_page_slap_add_computer_js web_page_module/rjs_gadget_erp5_page_slap_add_computer_js
web_page_module/rjs_gadget_erp5_page_slap_add_hosting_subscription_html web_page_module/rjs_gadget_erp5_page_slap_add_hosting_subscription_html
......
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