@ -531,7 +531,7 @@ document.getElementById('inviteForm').onsubmit = function() {
return false ;
return false ;
} ;
} ;
function tryLogin ( username , password , modal , button ) {
function tryLogin ( username , password , modal , button , callback ) {
let req = new XMLHttpRequest ( ) ;
let req = new XMLHttpRequest ( ) ;
req . responseType = 'json' ;
req . responseType = 'json' ;
req . onreadystatechange = function ( ) {
req . onreadystatechange = function ( ) {
@ -561,7 +561,6 @@ function tryLogin(username, password, modal, button) {
} else {
} else {
const data = this . response ;
const data = this . response ;
window . token = data [ 'token' ] ;
window . token = data [ 'token' ] ;
document . cookie = "refresh=" + data [ 'refresh' ] ;
generateInvites ( ) ;
generateInvites ( ) ;
const interval = setInterval ( function ( ) { generateInvites ( ) ; } , 60 * 1000 ) ;
const interval = setInterval ( function ( ) { generateInvites ( ) ; } , 60 * 1000 ) ;
let day = document . getElementById ( 'days' ) ;
let day = document . getElementById ( 'days' ) ;
@ -579,6 +578,9 @@ function tryLogin(username, password, modal, button) {
}
}
document . getElementById ( 'logoutButton' ) . setAttribute ( 'style' , '' ) ;
document . getElementById ( 'logoutButton' ) . setAttribute ( 'style' , '' ) ;
}
}
if ( typeof callback === "function" ) {
callback ( this . status ) ;
}
}
}
} ;
} ;
req . open ( "GET" , "/getToken" , true ) ;
req . open ( "GET" , "/getToken" , true ) ;
@ -600,7 +602,7 @@ document.getElementById('loginForm').onsubmit = function() {
button . innerHTML =
button . innerHTML =
'<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" style="margin-right: 0.5rem;"></span>' +
'<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" style="margin-right: 0.5rem;"></span>' +
'Loading...' ;
'Loading...' ;
tryLogin ( details[ 'username' ] , details[ 'password' ] , true , button )
tryLogin ( username = details[ 'username' ] , password = details[ 'password' ] , modal = true , button = button )
return false ;
return false ;
} ;
} ;
@ -807,12 +809,12 @@ document.getElementById('openUsers').onclick = function () {
generateInvites ( empty = true ) ;
generateInvites ( empty = true ) ;
let refreshToken = getCookie ( "refresh" )
tryLogin ( "" , "" , false , callback = function ( code ) {
if ( refreshToken != "" ) {
console . log ( code ) ;
tryLogin ( refreshToken , "" , false )
if ( code != 200 ) {
} else {
loginModal . show ( ) ;
loginModal . show ( ) ;
}
}
} ) ;
document . getElementById ( 'logoutButton' ) . onclick = function ( ) {
document . getElementById ( 'logoutButton' ) . onclick = function ( ) {
let req = new XMLHttpRequest ( ) ;
let req = new XMLHttpRequest ( ) ;
@ -822,7 +824,6 @@ document.getElementById('logoutButton').onclick = function () {
req . onreadystatechange = function ( ) {
req . onreadystatechange = function ( ) {
if ( this . readyState == 4 && this . status == 200 ) {
if ( this . readyState == 4 && this . status == 200 ) {
window . token = '' ;
window . token = '' ;
document . cookie = 'refresh=;' ;
location . reload ( ) ;
location . reload ( ) ;
return false ;
return false ;
}
}