Tidy up javascript OAuth code

This commit is contained in:
Tom Hughes 2013-03-28 11:11:51 +00:00
parent 15be6b3ffc
commit 00a4d9fe49

View file

@ -1,7 +1,6 @@
//= require sha //= require sha
//= require ohauth //= require ohauth
$(document).ready(function () {
$.ajaxPrefilter(function(options, jqxhr) { $.ajaxPrefilter(function(options, jqxhr) {
if (options.oauth) { if (options.oauth) {
var ohauth = window.ohauth; var ohauth = window.ohauth;
@ -14,19 +13,13 @@ $(document).ready(function () {
oauth_nonce: ohauth.nonce() oauth_nonce: ohauth.nonce()
}; };
for (var name in jqxhr.data) {
params[name] = jqxhr.data[name];
}
params.oauth_signature = ohauth.signature( params.oauth_signature = ohauth.signature(
OSM.oauth_consumer_secret, OSM.oauth_consumer_secret,
OSM.oauth_token_secret, OSM.oauth_token_secret,
ohauth.baseString(options.type, url, params) ohauth.baseString(options.type, url, $.extend({}, params, jqxhr.data))
); );
options.headers = { options.headers = options.headers || {};
Authorization: "OAuth " + ohauth.authHeader(params) options.headers.Authorization = "OAuth " + ohauth.authHeader(params);
};
} }
}); });
});