APmanageur Wi-Fi V1.0

This commit is contained in:
yoannmultigaming committed 2026-11-18 03:17:05 +01:00
1 parent 8770fe4f7a
commit eb6659dad2
2 files changed
+88 -54

No files matched your search

+30 -6
View File
@@ -3047,6 +3047,29 @@
};
}
function getSetupAuthToken(extraToken) {
if (extraToken) return extraToken;
try {
const m = document.cookie.match(/(?:^|;\s*)apAuthToken=([^;]+)/);
if (m && m[1]) return decodeURIComponent(m[1]);
} catch (_) { }
try {
return localStorage.getItem('apAuthToken') || sessionStorage.getItem('apAuthToken') || '';
} catch (_) {
return '';
}
}
function getSetupAuthHeaders(extraToken, jsonContent = true) {
const h = jsonContent ? { 'Content-Type': 'application/json' } : {};
const tok = getSetupAuthToken(extraToken);
if (tok) {
h['X-Session-Token'] = tok;
h['Authorization'] = 'Bearer ' + tok;
}
return h;
}
async function testSetupNotification(channel) {
const detailsBox = $('setupNotifTestDetails');
if (detailsBox) {
@@ -3059,7 +3082,7 @@
};
const res = await fetch(API_URL + '/api/notifications/test', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: getSetupAuthHeaders(),
body: JSON.stringify(payload)
});
const data = await res.json();
@@ -3099,7 +3122,9 @@
async function loadNotificationSettingsInSetup() {
try {
const res = await fetch(API_URL + '/api/notifications/settings');
const res = await fetch(API_URL + '/api/notifications/settings', {
headers: getSetupAuthHeaders('', false)
});
if (!res.ok) return;
const cfg = await res.json();
@@ -3576,7 +3601,7 @@
const b64 = e.target.result.split(',')[1];
const res = await fetch(API_URL + '/api/backup/inspect', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: getSetupAuthHeaders(),
body: JSON.stringify({ filename: file.name, data_base64: b64 })
});
const d = await res.json();
@@ -3658,7 +3683,7 @@
try {
const res = await fetch(API_URL + '/api/backup/import', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: getSetupAuthHeaders(),
body: JSON.stringify({ backup: pendingBackupData, options: options })
});
const d = await res.json();
@@ -3792,8 +3817,7 @@
}
} catch (_) { }
const headers = { 'Content-Type': 'application/json' };
if (token) headers['Authorization'] = 'Bearer ' + token;
const headers = getSetupAuthHeaders(token, true);
// C. Configuration du réseau Wi-Fi
msg.textContent = isEn ? '2/5 Configuring Wi-Fi Access Point…' : '2/5 Configuration du point d\'accès Wi-Fi…';