diff --git a/dspace-spring-rest/src/main/webapp/login.html b/dspace-spring-rest/src/main/webapp/login.html index 3936a6d43d..8ac8b71b4b 100644 --- a/dspace-spring-rest/src/main/webapp/login.html +++ b/dspace-spring-rest/src/main/webapp/login.html @@ -79,6 +79,26 @@ "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() { $.ajax({ //This depends on this file to be called login.html