X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/606e66beb32d2b683651cf9ac7ae575d90df7ad6..adc81f010d0e888a06684e3544b296fb85e520c8:/app/assets/javascripts/oauth.js?ds=sidebyside diff --git a/app/assets/javascripts/oauth.js b/app/assets/javascripts/oauth.js index 98ce302e1..0c3538c51 100644 --- a/app/assets/javascripts/oauth.js +++ b/app/assets/javascripts/oauth.js @@ -1,24 +1,11 @@ -//= require ohauth - $(document).ready(function () { - function makeAbsolute(url) { - var a = document.createElement('a'); - a.href = url; - return a.href; - } - - if (OSM.oauth_token) { - var headerGenerator = window.ohauth.headerGenerator({ - consumer_key: OSM.oauth_consumer_key, - consumer_secret: OSM.oauth_consumer_secret, - token: OSM.oauth_token, - token_secret: OSM.oauth_token_secret - }); + var application_data = $("head").data(); - $.ajaxPrefilter(function(options, jqxhr) { + if (application_data.oauthToken) { + $.ajaxPrefilter(function (options) { if (options.oauth) { options.headers = options.headers || {}; - options.headers.Authorization = headerGenerator(options.type, makeAbsolute(options.url), jqxhr.data); + options.headers.Authorization = "Bearer " + application_data.oauthToken; } }); }