Use Authorization header for session

issue4646
review15971002
This commit is contained in:
C?dric Krier 2016-03-15 16:58:46 +01:00
parent aa308d7d06
commit 497acc4177
2 changed files with 20 additions and 5 deletions

View file

@ -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);

View file

@ -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': '/',