I am doing a proof of concept on AngularJS and SpringMVC 5.x, Tomcat and single-sign-on (SSO) to login and logout from the application. When session is timed-out or Invalid session, the application is not redirected to login page. I am getting CORS error message.
Here is the sample JavaScript code for Invalid Session and Session timeout, please help how to apply CORS on the below code.
//Invalid Session
TestApp.factory('respInterceptor', function($location, $window, $cookies) {
return {
response: function(resp) {
//console.log(" Test : " + JSON.stringify(resp));
return resp;
},
responseError : function(error) {
console.log(" Error >>> : "+error.status )
if(error.status == 401 || error.status == 302) {
$cookies.JSESSIOINID = '';
console.log("invalid session");
window.location = "http://login.boshiftdev.com/app/ui/login.jsp";
}
}
};
})
//Session Timeout
$scope.logout = function() { $cookies.JSESSIOINID = '';
console.log("logout");
$http({
method: 'POST',
url: contextURL+'/logout',
headers: {'Content-Type': 'application/json'},
params: {data: $rootScope.userSession }
}).
success (function(data) {
$rootScope.userSession = null; $window.location = 'login.jsp';
window.location = ""
}).
error (function(data) {
$rootScope.userSession = null; $window.location= 'login.jsp';
console.error('');
});
}