Add redirect behavior

This commit is contained in:
Terry W Brady
2018-01-23 15:55:18 -08:00
parent fa94297a80
commit 3d135a4114

View File

@@ -79,6 +79,26 @@
"onclick" : function() { toastr.remove(); } "onclick" : function() { toastr.remove(); }
} }
$.ajax({
url : window.location.href.replace("login.html", "") + 'api/authn/login',
success : function(result, status, xhr) {
document.cookie = "MyHalBrowserToken=" + xhr.getResponseHeader('Authorization').split(" ")[1];
toastr.success('You are now logged in. Please wait while we redirect you...', 'Login Successful');
setTimeout(function() {
window.location.href = window.location.pathname.replace("login.html", "");
}, 2000);
},
error : function(result, status, xhr) {
if (xhr == 401) {
var loc = result.getResponseHeader("location");
if (loc != null && loc != "") {
document.location = loc;
}
}
}
});
$("#login").click(function() { $("#login").click(function() {
$.ajax({ $.ajax({
//This depends on this file to be called login.html //This depends on this file to be called login.html