block user in django admin
This commit is contained in:
1 parent
089db0afa4
commit
fe7a10cb61
19 files changed
+574
-11
No files matched your search
@@ -0,0 +1,25 @@
|
||||
(() => {
|
||||
const script = document.querySelector('script[data-customer-login-access]');
|
||||
if (!script) return;
|
||||
let pending = false;
|
||||
async function checkAccess() {
|
||||
if (pending || document.hidden) return;
|
||||
pending = true;
|
||||
try {
|
||||
const response = await fetch(script.dataset.customerLoginAccess, {
|
||||
credentials: 'same-origin', cache: 'no-store', headers: {Accept: 'application/json'}
|
||||
});
|
||||
if (!response.ok) return;
|
||||
const result = await response.json();
|
||||
if (!result.authenticated) window.location.replace(result.login_url);
|
||||
} catch (_) {
|
||||
// Retry on the next heartbeat or when the browser returns online.
|
||||
} finally {
|
||||
pending = false;
|
||||
}
|
||||
}
|
||||
window.setInterval(checkAccess, 10000);
|
||||
document.addEventListener('visibilitychange', checkAccess);
|
||||
window.addEventListener('pageshow', checkAccess);
|
||||
window.addEventListener('online', checkAccess);
|
||||
})();
|
||||
Reference in new issue
Block a user