From b69a0063ce453662b4363a0f6574af32609ae0ae Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Wed, 20 Jan 2016 12:04:58 -0500 Subject: #140 - handle Basic Auth properly by adding Authorization header in interceptor Former-commit-id: 494aec9837baa3c612f90c1f1d193e67a93fe0bc --- www/js/app.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'www/js') diff --git a/www/js/app.js b/www/js/app.js index 4c98d94d..6ab6bedf 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1,6 +1,6 @@ /* jshint -W041 */ /* jslint browser: true*/ -/* global cordova,StatusBar,angular,console,alert,PushNotification, moment ,ionic */ +/* global cordova,StatusBar,angular,console,alert,PushNotification, moment ,ionic, URI */ var appVersion = "0.0.0"; @@ -256,6 +256,21 @@ angular.module('zmApp', [ return { 'request': function (config) { + + // handle basic auth properly + if (config.url.indexOf("@") > -1) + { + // console.log ("HTTP basic auth INTERCEPTOR URL IS " + config.url); + var components = URI.parse(config.url); + //console.log ("Parsed data is " + JSON.stringify(components)); + var credentials = btoa(components.userinfo); + //var authorization = {'Authorization': 'Basic ' + credentials}; + config.headers.Authorization = 'Basic ' + credentials; + + //console.log ("Full headers: " + JSON.stringify(config.headers)); + + } + if (zmCookie) { config.headers.Cookie = "ZMSESSID=" + zmCookie; @@ -427,6 +442,7 @@ angular.module('zmApp', [ ZMDataModel.zmLog("Authentication is disabled. Skipping login"); ZMDataModel.zmLog("However, still doing a reachability check..."); + ZMDataModel.zmDebug ("LD.url is " + ld.url); $http.get(ld.url) .then(function (success) { ZMDataModel.zmLog(ld.url + " is reachable."); -- cgit v1.2.3