Commit d2a9980e authored by Romain Courteaud's avatar Romain Courteaud Committed by Sebastien Robin

Add loginform when requested by ERP5

parent d93b332b
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
$.mobile.linkBindingEnabled = false;\n $.mobile.linkBindingEnabled = false;\n
$.mobile.hashListeningEnabled = false;\n $.mobile.hashListeningEnabled = false;\n
$.mobile.pushStateEnabled = false;\n $.mobile.pushStateEnabled = false;\n
\n \n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
// Some functions\n // Some functions\n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
...@@ -135,7 +135,21 @@ ...@@ -135,7 +135,21 @@
]);\n ]);\n
});\n });\n
}\n }\n
\n \n
function renderLoginForm(gadget, options) {\n
document.querySelector("h1").textContent = "Login";\n
\n
return gadget.declareGadget("gadget_erp5_pt_loginform.html", {\n
scope: "login_gadget"\n
})\n
.push(function (sub_gadget) {\n
return RSVP.all([\n
sub_gadget.render(),\n
sub_gadget.getElement()\n
]);\n
});\n
}\n
\n
function renderJioDocument(gadget, options) {\n function renderJioDocument(gadget, options) {\n
var sub_options;\n var sub_options;\n
return gadget.getDeclaredGadget("jio_gadget")\n return gadget.getDeclaredGadget("jio_gadget")\n
...@@ -201,7 +215,7 @@ ...@@ -201,7 +215,7 @@
.ready(function (g) {\n .ready(function (g) {\n
g.props = {\n g.props = {\n
frontpage_gadget: "gadget_erp5_pt_frontpage.html",\n frontpage_gadget: "gadget_erp5_pt_frontpage.html",\n
hateoas_url: "https://softinst51669.host.vifib.net/erp5/web_site_module/hateoas/",\n hateoas_url: "hateoas/",\n
action_view: "action_object_view",\n action_view: "action_object_view",\n
default_view_reference: "view",\n default_view_reference: "view",\n
};\n };\n
...@@ -297,7 +311,13 @@ ...@@ -297,7 +311,13 @@
\n \n
// $.mobile.loading(\'show\');\n // $.mobile.loading(\'show\');\n
if (options.jio_key === undefined) {\n if (options.jio_key === undefined) {\n
if (options.page === "login") {\n
queue = renderLoginForm(gadget, options);\n
} else if (options.page === undefined) {\n
queue = renderFrontpage(gadget, options);\n queue = renderFrontpage(gadget, options);\n
} else {\n
throw new Error("Unknown page: " + options.page);\n
}\n
} else {\n } else {\n
if (options.view === undefined) {\n if (options.view === undefined) {\n
// Redirect to the default view\n // Redirect to the default view\n
...@@ -330,6 +350,11 @@ ...@@ -330,6 +350,11 @@
return $(element).trigger("create");\n return $(element).trigger("create");\n
})\n })\n
.push(undefined, function (error) {\n .push(undefined, function (error) {\n
if (error.status === 401) {\n
// Redirect to the login view\n
return gadget.aq_pleasePublishMyState({page: "login"})\n
.push(gadget.pleaseRedirectMyHash.bind(gadget));\n
}\n
console.error(error);\n console.error(error);\n
console.error(error.stack);\n console.error(error.stack);\n
// $.mobile.loading(\'hide\');\n // $.mobile.loading(\'hide\');\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_pt_loginform.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_pt_loginform_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
<!DOCTYPE html>\n
<html>\n
<head>\n
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>ERP5 PT Loginpage</title>\n
\n
<!-- renderjs -->\n
<script src="RSVP.js" type="text/javascript"></script>\n
<script src="renderjs.js" type="text/javascript"></script>\n
\n
<!-- custom script -->\n
<script src="gadget_global.js" type="text/javascript"></script>\n
<script src="gadget_erp5_pt_loginform.js" type="text/javascript"></script>\n
\n
</head>\n
<body>\n
\n
<fieldset class="center">\n
<form class="login_form">\n
<input type="text" data-enhanced="true" value="" name="login" required="required" />\n
<input type="password" data-enhanced="true" value="" name="password" required="required" />\n
<input data-enhanced="true" type="submit" value="Login">\n
</form>\n
</fieldset>\n
\n
</body>\n
</html>
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Loginform</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_pt_loginform.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_pt_loginform_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string>/*global rJS, RSVP, Handlebars, initGadgetMixin */\n
/*jslint nomen: true */\n
(function (window, rJS, RSVP) {\n
"use strict";\n
\n
rJS(window)\n
/////////////////////////////////////////////////////////////////\n
// ready\n
/////////////////////////////////////////////////////////////////\n
// Init local properties\n
.ready(function (g) {\n
g.props = {};\n
})\n
\n
// Assign the element to a variable\n
.ready(function (g) {\n
return g.getElement()\n
.push(function (element) {\n
g.props.element = element;\n
});\n
})\n
\n
/////////////////////////////////////////////////////////////////\n
// handle acquisition\n
/////////////////////////////////////////////////////////////////\n
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")\n
\n
/////////////////////////////////////////////////////////////////\n
// declared methods\n
/////////////////////////////////////////////////////////////////\n
.declareMethod("render", function (options) {\n
return "ok";\n
})\n
\n
.declareService(function () {\n
var form_gadget = this;\n
// Listen to form submit\n
return new RSVP.Queue()\n
.push(function () {\n
return promiseEventListener(\n
form_gadget.props.element.querySelector(\'form\'),\n
\'submit\',\n
false\n
);\n
})\n
.push(function (evt) {\n
var form = evt.target,\n
login = form.elements[0].value,\n
passwd = form.elements[1].value;\n
\n
document.cookie = "__ac=" + window.btoa(login + ":" + passwd);\n
// XXX Hardcoded non generic redirection to the frontpage\n
return form_gadget.pleaseRedirectMyHash("#");\n
\n
});\n
\n
});\n
}(window, rJS, RSVP));</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Login JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
17 18
\ No newline at end of file \ No newline at end of file
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