fix server-initiated success redirect JS
This commit is contained in:
parent
28bded7c52
commit
02a1f8ab5b
|
@ -23,8 +23,20 @@ evtSource.addEventListener('failed', (e) => {
|
|||
console.error(e.data);
|
||||
});
|
||||
|
||||
let hasFocus = true;
|
||||
window.addEventListener('blur', () => {
|
||||
hasFocus = false;
|
||||
});
|
||||
|
||||
evtSource.addEventListener('success', (e) => {
|
||||
waitingElem.classList.add('hidden');
|
||||
evtSource.close();
|
||||
window.location = `/withssb/finalize?token=${e.data}`;
|
||||
const redirectTo = `/withssb/finalize?token=${e.data}`
|
||||
if (hasFocus) {
|
||||
window.location.replace(redirectTo);
|
||||
} else {
|
||||
window.addEventListener('focus', () => {
|
||||
window.location.replace(redirectTo);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue