Upload 20 files
Browse files- static/app.js +11 -6
static/app.js
CHANGED
|
@@ -3,7 +3,7 @@ function hugpanel() {
|
|
| 3 |
// ── Auth State ──
|
| 4 |
user: null,
|
| 5 |
token: localStorage.getItem('hugpanel_token'),
|
| 6 |
-
adminApiUrl: '',
|
| 7 |
authLoading: true,
|
| 8 |
authMode: 'login',
|
| 9 |
authError: '',
|
|
@@ -81,7 +81,10 @@ function hugpanel() {
|
|
| 81 |
async init() {
|
| 82 |
// Load backup status to get adminApiUrl
|
| 83 |
await this.loadBackupStatus();
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
// Load config (MOTD, registration state, zone limit) early
|
| 87 |
await this._loadZoneLimit();
|
|
@@ -96,17 +99,18 @@ function hugpanel() {
|
|
| 96 |
const data = await resp.json();
|
| 97 |
this.user = data.user;
|
| 98 |
} else {
|
|
|
|
| 99 |
this.token = null;
|
| 100 |
localStorage.removeItem('hugpanel_token');
|
| 101 |
}
|
| 102 |
} catch {
|
| 103 |
-
// Worker unreachable —
|
| 104 |
-
this.token = null;
|
| 105 |
-
localStorage.removeItem('hugpanel_token');
|
| 106 |
}
|
|
|
|
|
|
|
| 107 |
} else {
|
|
|
|
| 108 |
this.token = null;
|
| 109 |
-
localStorage.removeItem('hugpanel_token');
|
| 110 |
}
|
| 111 |
|
| 112 |
this.authLoading = false;
|
|
@@ -281,6 +285,7 @@ function hugpanel() {
|
|
| 281 |
this.token = null;
|
| 282 |
this.user = null;
|
| 283 |
localStorage.removeItem('hugpanel_token');
|
|
|
|
| 284 |
localStorage.removeItem('hugpanel_zone');
|
| 285 |
localStorage.removeItem('hugpanel_tab');
|
| 286 |
this.currentZone = null;
|
|
|
|
| 3 |
// ── Auth State ──
|
| 4 |
user: null,
|
| 5 |
token: localStorage.getItem('hugpanel_token'),
|
| 6 |
+
adminApiUrl: localStorage.getItem('hugpanel_admin_url') || '',
|
| 7 |
authLoading: true,
|
| 8 |
authMode: 'login',
|
| 9 |
authError: '',
|
|
|
|
| 81 |
async init() {
|
| 82 |
// Load backup status to get adminApiUrl
|
| 83 |
await this.loadBackupStatus();
|
| 84 |
+
if (this.backupStatus.admin_url) {
|
| 85 |
+
this.adminApiUrl = this.backupStatus.admin_url;
|
| 86 |
+
localStorage.setItem('hugpanel_admin_url', this.adminApiUrl);
|
| 87 |
+
}
|
| 88 |
|
| 89 |
// Load config (MOTD, registration state, zone limit) early
|
| 90 |
await this._loadZoneLimit();
|
|
|
|
| 99 |
const data = await resp.json();
|
| 100 |
this.user = data.user;
|
| 101 |
} else {
|
| 102 |
+
// Token invalid/expired — clear it
|
| 103 |
this.token = null;
|
| 104 |
localStorage.removeItem('hugpanel_token');
|
| 105 |
}
|
| 106 |
} catch {
|
| 107 |
+
// Worker unreachable — keep token, let user retry
|
|
|
|
|
|
|
| 108 |
}
|
| 109 |
+
} else if (!this.adminApiUrl) {
|
| 110 |
+
// No admin URL available — can't verify token but don't clear it
|
| 111 |
} else {
|
| 112 |
+
// No token stored
|
| 113 |
this.token = null;
|
|
|
|
| 114 |
}
|
| 115 |
|
| 116 |
this.authLoading = false;
|
|
|
|
| 285 |
this.token = null;
|
| 286 |
this.user = null;
|
| 287 |
localStorage.removeItem('hugpanel_token');
|
| 288 |
+
localStorage.removeItem('hugpanel_admin_url');
|
| 289 |
localStorage.removeItem('hugpanel_zone');
|
| 290 |
localStorage.removeItem('hugpanel_tab');
|
| 291 |
this.currentZone = null;
|