diff --git a/src/rpc.js b/src/rpc.js index f82ca2f..f205873 100644 --- a/src/rpc.js +++ b/src/rpc.js @@ -13,13 +13,16 @@ var timeoutID = Sao.common.processing.show(); var ajax_prm = jQuery.ajax({ + 'headers': { + 'Authorization': 'Session ' + session.get_auth() + }, 'contentType': 'application/json', 'data': JSON.stringify(Sao.rpc.prepareObject({ 'method': args.method, - 'params': [session.user_id, session.session].concat(params) + 'params': params })), 'dataType': 'json', - 'url': '/' + (session.database || ''), + 'url': '/' + (session.database || '') + '/', 'type': 'post', 'complete': [function() { Sao.common.processing.hide(timeoutID); diff --git a/src/session.js b/src/session.js index 31927bb..96373b4 100644 --- a/src/session.js +++ b/src/session.js @@ -15,6 +15,9 @@ Sao.Session.current_session = this; } }, + get_auth: function() { + return btoa(this.login + ':' + this.user_id + ':' + this.session); + }, do_login: function(login, password) { var dfd = jQuery.Deferred(); var timeoutID = Sao.common.processing.show(); @@ -26,7 +29,7 @@ 'contentType': 'application/json', 'data': JSON.stringify(args), 'dataType': 'json', - 'url': '/' + this.database, + 'url': '/' + this.database + '/', 'type': 'post', 'complete': [function() { Sao.common.processing.hide(timeoutID); @@ -65,7 +68,16 @@ 'method': 'common.db.logout', 'params': [] }; - var prm = Sao.rpc(args, this); + var prm = jQuery.ajax({ + 'headers': { + 'Authorization': 'Session ' + this.get_auth() + }, + 'contentType': 'application/json', + 'data': JSON.stringify(args), + 'dataType': 'json', + 'url': '/' + this.database + '/', + 'type': 'post', + }); this.database = null; this.login = null; this.user_id = null; @@ -276,7 +288,7 @@ 'contentType': 'application/json', 'data': JSON.stringify({ 'method': 'common.db.list', - 'params': [null, null] + 'params': [] }), 'dataType': 'json', 'url': '/',