Commit 8708611d authored by Marc Duez's avatar Marc Duez
Browse files

server + database.js : add standard user controller(server side) and ajax form...

server + database.js : add standard user controller(server side) and ajax form to comunicate(client side)
parent 160e1b32
......@@ -100,6 +100,32 @@ Database.prototype = {
});
}
//login_form
if ( document.getElementById('login_form') ){
//$('#login_form').on('submit',self.login_form );
$('#login_form').ajaxForm({
type: "POST",
cache: false,
timeout: 1000,
crossDomain: true,
context: self,
url : $(this).attr('action'),
data : $(this).serialize(),
xhrFields: {withCredentials: true},
success: self.display_result,
error: function (request, status, error) {
if (status === "timeout") {
popupMsg("timeout");
} else {
self.call("patient/index")
}
}
});
}
//submit formulaire avec fichier
if ( document.getElementById('upload_form') ){
//$('#upload_form').on('submit', self.upload_form ); // doesn't work :/
......@@ -158,6 +184,33 @@ Database.prototype = {
},
login_form: function (e) {
var self = this
e.preventDefault();
e.stopPropagation();
//login_form
$.ajax({
type: "POST",
cache: false,
timeout: 1000,
crossDomain: true,
url : $(this).attr('action'),
data : $(this).serialize(),
xhrFields: {withCredentials: true},
success: self.display_result(result),
error: function (request, status, error) {
if (status === "timeout") {
popupMsg("timeout");
} else {
popupMsg(request.responseText);
}
}
});
},
/* ajax event pour formulaire sans fichier
* */
data_form: function (e) {
......
......@@ -231,3 +231,24 @@ def delete_file():
def upload():
return dict()
def user():
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Max-Age'] = 86400
"""
exposes:
http://..../[app]/default/user/login
http://..../[app]/default/user/logout
http://..../[app]/default/user/register
http://..../[app]/default/user/profile
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/user/change_password
http://..../[app]/default/user/manage_users (requires membership in
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())
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