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