Commit a5c833b4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: User can now add extra Logins on his account

parent 90833180
<!DOCTYPE html>
<html>
<!--
data-i18n=Slapos
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Site List</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_page_slap_person_add_erp5_login.js" type="text/javascript"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.onEvent('submit', function () {
var gadget = this,
doc = {};
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (content) {
var k;
for (k in content) {
if (k !== "password_confirmation") {
doc[k] = content[k];
}
if ((k === "password_confirmation") &&
(content.password !== content.password_confirmation)) {
return gadget.notifySubmitted({message: 'Password is different from confirmation', status: 'error'});
}
}
return gadget.getSetting("hateoas_url")
.push(function (hateoas_url) {
return gadget.jio_putAttachment(content.parent_relative_url,
hateoas_url + gadget.state.jio_key + "/Person_newLogin", doc)
.push(function () {
return gadget.notifySubmitted({message: 'New User Login created.', status: 'success'});
})
.push(function () {
return gadget.redirect({"command": "change",
"options": {"jio_key": content.parent_relative_url,
"page": "slap_controller"}});
});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this;
gadget.state.jio_key = options.jio_key;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view')
]);
})
.push(function (result) {
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_reference": {
"description": "",
"title": "Login Name",
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "reference",
"hidden": 0,
"type": "StringField"
},
"my_new_password": {
"description": "",
"title": "Password",
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "password",
"hidden": 0,
"type": "PasswordField"
},
"my_confirmation_password": {
"description": "",
"title": "Confirm your Password",
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "password_confirmation",
"hidden": 0,
"type": "PasswordField"
},
"my_portal_type": {
"description": "The name of a document in ERP5",
"title": "Portal Type",
"default": "ERP5 Login",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": "Parent Relative Url",
"default": gadget.state.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_reference"], ["my_new_password"], ["my_confirmation_password"], ["my_portal_type"], ["my_parent_relative_url"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'change', options: {page: "slap_controller"}})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: "Add New User Login",
selection_url: url_list[0],
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -91,8 +91,7 @@
var gadget = this,
column_list = [
['reference', 'Reference'],
['portal_type', 'Type'],
['validation_state', 'Status']
['portal_type', 'Type']
],
data;
return new RSVP.Queue()
......@@ -149,7 +148,8 @@
"query": "urn:jio:allDocs?query=%28portal_type%3A%28%22" +
"ERP5 Login" + "%22%2C%20%22" +
"Google Login" + "%22%2C%20%22" +
"Facebook Login" + "%22%29%29",
"Facebook Login" + "%22%29%20AND%20" +
"validation_state%3Avalidated%29",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
......@@ -185,6 +185,7 @@
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_revoke_certificate"}}),
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_request_certificate"}}),
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_get_token"}}),
gadget.getUrlFor({command: "change", options: {jio_key: me, page: "slap_person_add_erp5_login"}}),
gadget.getUrlFor({command: "change", options: {page: "slapos"}})
]);
})
......@@ -195,7 +196,8 @@
request_certificate_url: url_list[2],
revoke_certificate_url: url_list[1],
token_url: url_list[3],
selection_url: url_list[4]
add_url: url_list[4],
selection_url: url_list[5]
};
if (!gadget.state.editable) {
header_dict.edit_content = url_list[0];
......
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.32024.53732.34406</string> </value>
<value> <string>976.3552.39636.23859</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1545663870.65</float>
<float>1559517473.11</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -269,6 +269,8 @@ gadget_erp5_page_slap_add_software_installation.html\n
gadget_erp5_page_slap_add_software_installation.js\n
gadget_erp5_page_slap_add_ticket.html\n
gadget_erp5_page_slap_add_ticket.js\n
gadget_erp5_page_slap_close_ticket.js\n
gadget_erp5_page_slap_close_ticket.html\n
gadget_erp5_page_slap_computer_get_token.html\n
gadget_erp5_page_slap_computer_get_token.js\n
gadget_erp5_page_slap_computer_list.html\n
......@@ -360,8 +362,6 @@ gadget_erp5_page_slap_support_request_view.html\n
gadget_erp5_page_slap_ticket_list.html\n
gadget_erp5_page_slap_ticket_list.js\n
gadget_erp5_page_slap_ticket_view.js\n
gadget_erp5_page_slap_close_ticket.js\n
gadget_erp5_page_slap_close_ticket.html\n
gadget_erp5_page_slap_transfer_computer.html\n
gadget_erp5_page_slap_transfer_computer.js\n
gadget_erp5_page_slap_trial_request_message.html\n
......@@ -370,6 +370,8 @@ gadget_erp5_page_slap_upgrade_decision_view.html\n
gadget_erp5_page_slap_upgrade_decision_view.js\n
gadget_erp5_page_slap_invalidate_login.js\n
gadget_erp5_page_slap_invalidate_login.html\n
gadget_erp5_page_slap_person_add_erp5_login.js\n
gadget_erp5_page_slap_person_add_erp5_login.html\n
gadget_erp5_page_slapos.css\n
gadget_erp5_page_slapos.html\n
gadget_erp5_page_slapos.js\n
......@@ -549,7 +551,7 @@ NETWORK:\n
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -563,7 +565,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.57226.29060.57429</string> </value>
<value> <string>976.8845.38902.19200</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -581,7 +583,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1558489648.02</float>
<float>1559518993.22</float>
<string>UTC</string>
</tuple>
</state>
......
from zExceptions import Unauthorized
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person.getUid() != context.getUid():
raise Unauthorized("You are not allowed to create login to a different user")
if context.Person_testLoginExistence(reference=reference):
raise Unauthorized("Login already exists")
erp5_login = context.newContent(
portal_type = "ERP5 Login",
reference=reference,
password=password
)
erp5_login.validate()
return erp5_login.getRelativeUrl()
<?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>reference, password</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_newLogin</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
return portal.portal_catalog.countResults(
portal_type=["ERP5 Login", "Google Login", "Facebook Login"],
reference=reference,
validation_state="validated"
)[0][0] > 0
<?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>reference, REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_testLoginExistence</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
image_module/gadget_slapos_panel_png
web_page_module/rjs_gadget_translation_data_js
web_page_module/rjs_gadget_slapos_alert_listbox_field_css
web_page_module/rjs_gadget_slapos_alert_listbox_field_html
web_page_module/rjs_gadget_slapos_alert_listbox_field_js
web_page_module/gadget_erp5_page_slap_reject_upgrade_decision_html
web_page_module/gadget_erp5_page_slap_reject_upgrade_decision_js
web_page_module/rjs_gadget_erp5_attention_point_css
web_page_module/rjs_gadget_erp5_attention_point_html
web_page_module/rjs_gadget_erp5_attention_point_js
web_page_module/gadget_erp5_page_slap_reject_upgrade_decision_html
web_page_module/gadget_erp5_page_slap_reject_upgrade_decision_js
web_page_module/rjs_gadget_erp5_page_map_css
web_page_module/rjs_gadget_erp5_page_map_html
web_page_module/rjs_gadget_erp5_page_map_js
......@@ -31,6 +27,8 @@ web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_html
web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_js
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_computer_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_computer_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_computer_list_html
......@@ -79,6 +77,8 @@ web_page_module/rjs_gadget_erp5_page_slap_parameter_form_css
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_html
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_payment_result_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_erp5_login_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_erp5_login_js
web_page_module/rjs_gadget_erp5_page_slap_person_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_person_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_person_request_certificate_html
......@@ -122,8 +122,6 @@ web_page_module/rjs_gadget_erp5_page_slap_support_request_view_html
web_page_module/rjs_gadget_erp5_page_slap_ticket_list_html
web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js
web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html
......@@ -143,6 +141,9 @@ web_page_module/rjs_gadget_erp5_panel_shortcut_html
web_page_module/rjs_gadget_erp5_panel_shortcut_js
web_page_module/rjs_gadget_erp5_pt_form_slapos_index_html
web_page_module/rjs_gadget_erp5_pt_form_slapos_index_js
web_page_module/rjs_gadget_slapos_alert_listbox_field_css
web_page_module/rjs_gadget_slapos_alert_listbox_field_html
web_page_module/rjs_gadget_slapos_alert_listbox_field_js
web_page_module/rjs_gadget_slapos_appcache
web_page_module/rjs_gadget_slapos_computer_map_html
web_page_module/rjs_gadget_slapos_computer_map_js
......@@ -175,6 +176,7 @@ web_page_module/rjs_gadget_slapos_project_status_html
web_page_module/rjs_gadget_slapos_project_status_js
web_page_module/rjs_gadget_slapos_site_status_html
web_page_module/rjs_gadget_slapos_site_status_js
web_page_module/rjs_gadget_translation_data_js
web_page_module/rjs_gadget_trial_panel_html
web_page_module/rjs_gadget_trial_panel_js
web_page_module/rjs_leaflet_css
......
......@@ -77,6 +77,8 @@ web_page_module/rjs_gadget_erp5_page_slap_parameter_form_css
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_html
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_payment_result_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_erp5_login_html
web_page_module/rjs_gadget_erp5_page_slap_person_add_erp5_login_js
web_page_module/rjs_gadget_erp5_page_slap_person_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_person_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_person_request_certificate_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