AP manageur V1.1 (Bêta)
This commit is contained in:
1 parent
c35a2fcfa3
commit
7114691e0a
4 files changed
+87
-5
No files matched your search
+81
-5
@@ -468,6 +468,12 @@
|
||||
opacity: .9
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: .55;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
button.secondary {
|
||||
background: var(--panel2);
|
||||
color: var(--text);
|
||||
@@ -8080,8 +8086,51 @@
|
||||
return String(s).replace(/[&<>"']/g, ch => '&#' + ch.charCodeAt(0) + ';');
|
||||
}
|
||||
|
||||
let authBusy = false;
|
||||
function setAuthLoading(busy, loadingText) {
|
||||
authBusy = !!busy;
|
||||
const submitBtn = $('authSubmit');
|
||||
const passkeyBtn = $('btnAuthPasskey');
|
||||
const togglePwdBtn = $('toggleAuthPassword');
|
||||
const userInput = $('authUsername');
|
||||
const pwdInput = $('authPassword');
|
||||
const otpInput = $('authOtp');
|
||||
const remCheck = $('rememberUser');
|
||||
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = busy;
|
||||
submitBtn.style.opacity = busy ? '0.75' : '';
|
||||
submitBtn.style.cursor = busy ? 'wait' : '';
|
||||
submitBtn.style.pointerEvents = busy ? 'none' : '';
|
||||
if (busy) {
|
||||
const txt = loadingText || t('auth_checking', 'Vérification…');
|
||||
submitBtn.innerHTML = `<span style="display:inline-flex;align-items:center;justify-content:center;animation:spin 1s linear infinite">⚙️</span> <span>${escapeHtml(txt)}</span>`;
|
||||
} else {
|
||||
submitBtn.textContent = authSetupMode ? t('auth_setup_submit', 'Créer le compte') : t('auth_submit', 'Se connecter');
|
||||
}
|
||||
}
|
||||
|
||||
if (passkeyBtn) {
|
||||
passkeyBtn.disabled = busy;
|
||||
passkeyBtn.style.opacity = busy ? '0.55' : '';
|
||||
passkeyBtn.style.cursor = busy ? 'wait' : '';
|
||||
passkeyBtn.style.pointerEvents = busy ? 'none' : '';
|
||||
}
|
||||
|
||||
if (togglePwdBtn) {
|
||||
togglePwdBtn.disabled = busy;
|
||||
togglePwdBtn.style.pointerEvents = busy ? 'none' : '';
|
||||
}
|
||||
|
||||
if (userInput) userInput.disabled = busy;
|
||||
if (pwdInput) pwdInput.disabled = busy;
|
||||
if (otpInput) otpInput.disabled = busy;
|
||||
if (remCheck) remCheck.disabled = busy;
|
||||
}
|
||||
|
||||
function showAuth(setup) {
|
||||
authSetupMode = setup;
|
||||
setAuthLoading(false);
|
||||
if ($('authView')) $('authView').classList.add('active');
|
||||
if ($('app')) $('app').style.display = 'none';
|
||||
if ($('authTitle')) {
|
||||
@@ -14039,7 +14088,13 @@ ${vpnBadgeTopo}
|
||||
};
|
||||
|
||||
$('authSubmit').onclick = async () => {
|
||||
const message = $('authMessage'); message.textContent = t('auth_processing', 'Traitement…');
|
||||
if (authBusy) return;
|
||||
const message = $('authMessage');
|
||||
if (message) {
|
||||
message.style.color = 'var(--text)';
|
||||
message.textContent = t('auth_checking', 'Vérification…');
|
||||
}
|
||||
setAuthLoading(true, t('auth_checking', 'Vérification…'));
|
||||
try {
|
||||
const path = authSetupMode ? '/api/auth/setup' : '/api/login';
|
||||
const devName = localStorage.getItem('apDeviceName') || '';
|
||||
@@ -14047,7 +14102,12 @@ ${vpnBadgeTopo}
|
||||
if (devName) authHeaders['X-Device-Name'] = encodeURIComponent(devName);
|
||||
const response = await fetch(API_URL + path, { method: 'POST', headers: authHeaders, body: JSON.stringify({ username: $('authUsername').value, password: $('authPassword').value, otp: $('authOtp').value.trim(), device_name: devName }) });
|
||||
const data = await response.json(); if (!response.ok) throw Error(data.error || 'Authentification refusée');
|
||||
if (authSetupMode) { message.textContent = t('auth_account_created', 'Compte créé. Connexion…'); authSetupMode = false; return $('authSubmit').click() }
|
||||
if (authSetupMode) {
|
||||
if (message) message.textContent = t('auth_account_created', 'Compte créé. Connexion…');
|
||||
authSetupMode = false;
|
||||
setAuthLoading(false);
|
||||
return $('authSubmit').click();
|
||||
}
|
||||
authToken = data.token;
|
||||
sessionStorage.setItem('apAuthToken', authToken);
|
||||
localStorage.setItem('apAuthToken', authToken);
|
||||
@@ -14063,13 +14123,24 @@ ${vpnBadgeTopo}
|
||||
showApp();
|
||||
hideLoaderScreen();
|
||||
}
|
||||
} catch (e) { message.textContent = tErr(e.message); }
|
||||
} catch (e) {
|
||||
if (message) {
|
||||
message.style.color = 'var(--red)';
|
||||
message.textContent = tErr(e.message);
|
||||
}
|
||||
setAuthLoading(false);
|
||||
if ($('authPassword')) {
|
||||
$('authPassword').focus();
|
||||
$('authPassword').select();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ($('authUsername')) {
|
||||
$('authUsername').addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if (authBusy) return;
|
||||
if ($('authPassword')) {
|
||||
$('authPassword').focus();
|
||||
$('authPassword').select();
|
||||
@@ -14082,7 +14153,8 @@ ${vpnBadgeTopo}
|
||||
$('authPassword').addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if ($('authSubmit')) $('authSubmit').click();
|
||||
if (authBusy) return;
|
||||
if ($('authSubmit') && !$('authSubmit').disabled) $('authSubmit').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14091,7 +14163,8 @@ ${vpnBadgeTopo}
|
||||
$('authOtp').addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if ($('authSubmit')) $('authSubmit').click();
|
||||
if (authBusy) return;
|
||||
if ($('authSubmit') && !$('authSubmit').disabled) $('authSubmit').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14577,6 +14650,7 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
|
||||
async function loginWithPasskey() {
|
||||
if (authBusy) return;
|
||||
const msgEl = $('authMessage');
|
||||
if (msgEl) { msgEl.textContent = ''; msgEl.style.color = 'var(--muted)'; }
|
||||
if (!window.PublicKeyCredential) {
|
||||
@@ -14586,6 +14660,7 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
return;
|
||||
}
|
||||
setAuthLoading(true, t('passkey_authenticating', 'Authentification Passkey…'));
|
||||
if (msgEl) {
|
||||
msgEl.style.color = 'var(--blue)';
|
||||
msgEl.textContent = t('passkey_waiting_validation', 'Présentez votre empreinte (Touch ID), votre visage (Face ID) ou touchez votre clé…');
|
||||
@@ -14658,6 +14733,7 @@ ${vpnBadgeTopo}
|
||||
msgEl.style.color = 'var(--red)';
|
||||
msgEl.textContent = t('passkey_error_prefix', 'Erreur Passkey : ') + tErr(e.message);
|
||||
}
|
||||
setAuthLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ window.I18N['en-gb'] = {
|
||||
"auth_setup_submit": "Create Account",
|
||||
"auth_otp_placeholder": "6-digit code or backup code (e.g. ABCDE-12345)",
|
||||
"auth_processing": "Processing…",
|
||||
"auth_checking": "Verifying…",
|
||||
"auth_account_created": "Account created. Signing in…",
|
||||
"passkey_authenticating": "Passkey authentication…",
|
||||
"passkey_auth_success": "Passkey authentication successful!",
|
||||
"passkey_login_rejected": "Passkey authentication rejected",
|
||||
"passkey_error_prefix": "Passkey error: ",
|
||||
|
||||
@@ -66,7 +66,9 @@ window.I18N['en-us'] = {
|
||||
"auth_setup_submit": "Create Account",
|
||||
"auth_otp_placeholder": "6-digit code or backup code (e.g. ABCDE-12345)",
|
||||
"auth_processing": "Processing…",
|
||||
"auth_checking": "Verifying…",
|
||||
"auth_account_created": "Account created. Signing in…",
|
||||
"passkey_authenticating": "Passkey authentication…",
|
||||
"passkey_auth_success": "Passkey authentication successful!",
|
||||
"passkey_login_rejected": "Passkey authentication rejected",
|
||||
"passkey_error_prefix": "Passkey error: ",
|
||||
|
||||
@@ -66,7 +66,9 @@ window.I18N['fr'] = {
|
||||
"auth_setup_submit": "Créer le compte",
|
||||
"auth_otp_placeholder": "Code à 6 chiffres ou code de secours (ex: ABCDE-12345)",
|
||||
"auth_processing": "Traitement…",
|
||||
"auth_checking": "Vérification…",
|
||||
"auth_account_created": "Compte créé. Connexion…",
|
||||
"passkey_authenticating": "Authentification Passkey…",
|
||||
"passkey_auth_success": "Authentification Passkey réussie !",
|
||||
"passkey_login_rejected": "Connexion Passkey refusée",
|
||||
"passkey_error_prefix": "Erreur Passkey : ",
|
||||
|
||||
Reference in new issue
Block a user