Add 401 redirect handling in frontend
JavaScript now checks for 401 status and redirects to login page when session expires. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a6d1901fe5
commit
0a946ba2ac
1 changed files with 8 additions and 0 deletions
|
|
@ -270,6 +270,10 @@ function ensureTrailingEmpty() {
|
|||
async function init() {
|
||||
try {
|
||||
var res = await fetch("/hm-ems-report/api/files");
|
||||
if (res.status === 401) {
|
||||
window.location.href = "/login";
|
||||
return;
|
||||
}
|
||||
var files = await res.json();
|
||||
|
||||
var sel = document.getElementById("fileSelector");
|
||||
|
|
@ -294,6 +298,10 @@ async function loadCampaign(filename) {
|
|||
showLoading(true);
|
||||
try {
|
||||
var res = await fetch("/hm-ems-report/api/load/" + encodeURIComponent(filename));
|
||||
if (res.status === 401) {
|
||||
window.location.href = "/login";
|
||||
return;
|
||||
}
|
||||
var payload = await res.json();
|
||||
|
||||
RAW_DATA = payload.data;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue