mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Consolidate success handler
This commit is contained in:
@@ -61,6 +61,13 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var successHandler = 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);
|
||||
};
|
||||
toastr.options = {
|
||||
"closeButton": false,
|
||||
"debug": false,
|
||||
@@ -81,13 +88,7 @@
|
||||
|
||||
$.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);
|
||||
},
|
||||
success : successHandler,
|
||||
error : function(result, status, xhr) {
|
||||
if (xhr == 401) {
|
||||
var loc = result.getResponseHeader("location");
|
||||
@@ -110,13 +111,7 @@
|
||||
"Content-Type" : 'application/x-www-form-urlencoded',
|
||||
"Accept:" : '*/*'
|
||||
},
|
||||
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);
|
||||
},
|
||||
success : successHandler,
|
||||
error : function() {
|
||||
toastr.error('The credentials you entered are invalid. Please try again.', 'Login Failed');
|
||||
}
|
||||
|
Reference in New Issue
Block a user