I have a angularjs application which is deployed on app server and we have a single sign on web server which on successful authentication redirects to our application with the username in the response headers.
I have to read the username from the response headers when the angularjs application loads and use it to show on my application.
What i have tried:
Used as below in my app.js :
angular .module('myApp', [ 'ngResource', 'ngRoute', 'cgBusy', 'ui.bootstrap', 'ui.grid', 'ui.grid.pagination', 'ui.grid.moveColumns', 'ui.grid.selection', 'ui.grid.exporter', 'ngMaterial', 'angular-dropdown-multiselect' ]) .run(["$rootScope", function ($rootScope){
var checkIfAuthenticated = function (next) { console.log('Inside checkIfAuthenticated ---> ' + next); var matchedData = next.match( /[\?\&]username=([^\&]+)/); console.log('Inside checkIfAuthenticated matchedData ---> ' + matchedData); var proxyUserMatch = next.match( /[\?\&]username=([^\&]+)/); console.log('Inside checkIfAuthenticated proxyUserMatch ---> ' + proxyUserMatch) }; var firstTimeRoute = $rootScope.$on("$locationChangeStart", function(event, next, current) { console.log( "route change (first time)->current=[" + current + "], next=[" + next + "]"); checkIfAuthenticated( next); firstTimeRoute(); // opt out of the event }); }]);