APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
e54d1b2a7b
commit
77fd75e09b
3 files changed
+35
-23
No files matched your search
@@ -8928,6 +8928,15 @@ class Handler(BaseHTTPRequestHandler):
|
||||
update_background_metrics()
|
||||
self.send_json({'ok':True,'message':'Journaux supprimés'}); return
|
||||
if self.path == '/api/data/clear':
|
||||
# Arrêter les tunnels VPN actifs avant suppression
|
||||
try:
|
||||
c_v = db()
|
||||
v_rows = c_v.execute('SELECT id FROM vpn_profiles').fetchall()
|
||||
c_v.close()
|
||||
for (vpid,) in v_rows:
|
||||
try: disconnect_vpn_profile(vpid)
|
||||
except Exception: pass
|
||||
except Exception: pass
|
||||
name = connection_name()
|
||||
names_to_delete = set()
|
||||
if name: names_to_delete.add(name)
|
||||
@@ -8940,7 +8949,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if n:
|
||||
subprocess.run(['nmcli', 'connection', 'down', n], capture_output=True, text=True)
|
||||
subprocess.run(['nmcli', 'connection', 'delete', n], capture_output=True, text=True)
|
||||
stop_hostapd(INTERFACE)
|
||||
teardown_bridge()
|
||||
teardown_ap_nat()
|
||||
try: os.remove(CONNECTION_FILE)
|
||||
except OSError: pass
|
||||
try: os.remove(UPTIME_FILE)
|
||||
@@ -8955,15 +8966,22 @@ class Handler(BaseHTTPRequestHandler):
|
||||
c.execute('DELETE FROM client_names')
|
||||
c.execute('DELETE FROM client_traffic')
|
||||
c.execute('DELETE FROM client_traffic_daily')
|
||||
c.execute('DELETE FROM client_limits')
|
||||
c.execute('DELETE FROM vpn_profiles')
|
||||
c.execute('DELETE FROM client_vpn_routes')
|
||||
c.execute('DELETE FROM auth_users')
|
||||
c.execute('DELETE FROM auth_passkeys')
|
||||
c.execute('DROP TABLE IF EXISTS recovery_codes')
|
||||
c.execute('DELETE FROM preferences')
|
||||
c.execute('DELETE FROM auth_sessions')
|
||||
c.commit(); c.close()
|
||||
sessions.clear()
|
||||
invalidate_status_cache()
|
||||
try: sync_vpn_client_rules()
|
||||
except Exception: pass
|
||||
with traffic_lock: station_traffic.clear()
|
||||
log('reinitialisation_donnees', 'Système', request_ip(self), 'SYSTEM')
|
||||
self.send_json({'ok':True,'message':'Toutes les données et le point d’accès ont été réinitialisés et supprimés'}); return
|
||||
self.send_json({'ok':True,'message':'Toutes les données et le point d’accès ont été réinitialisés et supprimés','redirect':'/setup'}); return
|
||||
if self.path == '/api/auth/2fa/status':
|
||||
self.send_json({'enabled':auth_state()['two_factor'],'recovery_remaining':recovery_remaining()}); return
|
||||
if self.path == '/api/auth/2fa/enable':
|
||||
|
||||
+14
-20
@@ -54,26 +54,9 @@
|
||||
fetch('/api/auth/status', { cache: 'no-store' })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) {
|
||||
if (d) {
|
||||
var isDone = !!(d.setup_completed !== undefined ? d.setup_completed : (d.configured && d.wifi_configured));
|
||||
if (!isDone && !d.configured && !d.wifi_configured) {
|
||||
if (d && !d.configured) {
|
||||
window.location.replace('/setup');
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
} catch (_) {}
|
||||
|
||||
try {
|
||||
fetch('/api/auth/status', { cache: 'no-store' })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) {
|
||||
if (d) {
|
||||
var isDone = !!(d.setup_completed !== undefined ? d.setup_completed : (d.configured && d.wifi_configured));
|
||||
if (!isDone && !d.configured && !d.wifi_configured) {
|
||||
window.location.replace('/setup');
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
} catch (_) {}
|
||||
@@ -12974,7 +12957,18 @@ ${vpnBadgeTopo}
|
||||
try {
|
||||
const response = await apiFetch('/api/data/clear', { method: 'POST' }); const data = await response.json();
|
||||
if (!response.ok) throw Error(data.error || 'Suppression refusée');
|
||||
message.textContent = tMsg(data.message); await new Promise(resolve => setTimeout(resolve, 500)); await load();
|
||||
message.textContent = tMsg(data.message);
|
||||
authToken = '';
|
||||
try {
|
||||
sessionStorage.removeItem('apAuthToken');
|
||||
localStorage.removeItem('apAuthToken');
|
||||
sessionStorage.removeItem('apAppStarted');
|
||||
localStorage.removeItem('apAppStarted');
|
||||
sessionStorage.removeItem('apVisited');
|
||||
clearAuthCookie();
|
||||
} catch (_) {}
|
||||
await new Promise(resolve => setTimeout(resolve, 600));
|
||||
window.location.replace('/setup');
|
||||
} catch (e) { message.textContent = tErr(e.message); }
|
||||
});
|
||||
|
||||
@@ -14523,7 +14517,7 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
authConfigured = !!data.configured; authTwoFactor = !!data.two_factor;
|
||||
const isSetupDone = !!(data.setup_completed !== undefined ? data.setup_completed : (data.configured && data.wifi_configured));
|
||||
if (!isSetupDone && !data.configured && !data.wifi_configured) {
|
||||
if (!authConfigured || (!isSetupDone && !data.wifi_configured)) {
|
||||
hideLoaderScreen();
|
||||
window.location.replace('/setup');
|
||||
return;
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) {
|
||||
if (d) {
|
||||
var alreadyConfigured = !!(d.configured || d.wifi_configured || d.setup_completed);
|
||||
var alreadyConfigured = !!(d.configured || d.setup_completed);
|
||||
if (alreadyConfigured) {
|
||||
window.location.replace('/');
|
||||
}
|
||||
@@ -3724,7 +3724,7 @@
|
||||
authConfigured = !!dAuth.configured;
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const isForced = params.has('force') || params.has('reconfigure');
|
||||
const alreadyConfigured = !!(dAuth.configured || dAuth.wifi_configured || dAuth.setup_completed);
|
||||
const alreadyConfigured = !!(dAuth.configured || dAuth.setup_completed);
|
||||
|
||||
if (alreadyConfigured && !isForced) {
|
||||
window.location.replace('/');
|
||||
|
||||
Reference in new issue
Block a user