AP manageur V1.2 (Bêta)
This commit is contained in:
1 parent
ff840ae03e
commit
a53fa69034
5 files changed
+156
-4
No files matched your search
+133
-2
@@ -3387,7 +3387,7 @@
|
||||
<input id="authSettingsUsername" type="text" maxlength="32">
|
||||
<label class="label" for="authSettingsPassword" data-i18n="settings_admin_new_pwd_label">Nouveau mot de
|
||||
passe</label>
|
||||
<div style="display:flex;gap:8px;margin:7px 0 16px">
|
||||
<div style="display:flex;gap:8px;margin:7px 0 6px">
|
||||
<input id="authSettingsPassword" type="password" minlength="8" maxlength="128"
|
||||
placeholder="Nouveau mot de passe" data-i18n-placeholder="placeholder_new_pwd" style="margin:0">
|
||||
<button id="toggleAuthSettingsPassword" class="secondary" type="button"
|
||||
@@ -3399,9 +3399,19 @@
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg></button>
|
||||
</div>
|
||||
<div id="pwdStrengthWrap_new" style="margin:0 0 16px;display:none">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;font-size:11.5px">
|
||||
<span class="muted" data-i18n="pwd_strength_label">Force du mot de passe :</span>
|
||||
<span id="pwdStrengthText_new" style="font-weight:700"></span>
|
||||
</div>
|
||||
<div style="height:4px;background:var(--line);border-radius:4px;overflow:hidden">
|
||||
<div id="pwdStrengthBar_new" style="height:100%;width:0%;border-radius:4px;transition:width .25s ease, background-color .25s ease"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="label" for="authSettingsPasswordConfirm" data-i18n="settings_admin_confirm_pwd_label">Confirmation
|
||||
du mot de passe</label>
|
||||
<div style="display:flex;gap:8px;margin:7px 0 16px">
|
||||
<div style="display:flex;gap:8px;margin:7px 0 6px">
|
||||
<input id="authSettingsPasswordConfirm" type="password" minlength="8" maxlength="128"
|
||||
placeholder="Confirmation du mot de passe" data-i18n-placeholder="placeholder_pwd_confirm" style="margin:0">
|
||||
<button id="toggleAuthSettingsPasswordConfirm" class="secondary" type="button"
|
||||
@@ -3413,6 +3423,18 @@
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg></button>
|
||||
</div>
|
||||
<div id="pwdStrengthWrap_confirm" style="margin:0 0 16px;display:none">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;font-size:11.5px">
|
||||
<span class="muted" data-i18n="pwd_strength_label">Force du mot de passe :</span>
|
||||
<div style="display:flex;align-items:center;gap:6px">
|
||||
<span id="pwdMatchText_confirm" style="font-size:11px;font-weight:600"></span>
|
||||
<span id="pwdStrengthText_confirm" style="font-weight:700"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="height:4px;background:var(--line);border-radius:4px;overflow:hidden">
|
||||
<div id="pwdStrengthBar_confirm" style="height:100%;width:0%;border-radius:4px;transition:width .25s ease, background-color .25s ease"></div>
|
||||
</div>
|
||||
</div>
|
||||
<label class="label" for="authCurrentPassword" data-i18n="settings_admin_current_pwd_label">Mot de passe
|
||||
actuel</label>
|
||||
<div style="display:flex;gap:8px;margin:7px 0 16px">
|
||||
@@ -7859,6 +7881,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof updatePasswordStrengthIndicator === 'function') {
|
||||
try {
|
||||
updatePasswordStrengthIndicator('new');
|
||||
updatePasswordStrengthIndicator('confirm');
|
||||
} catch (_) { }
|
||||
}
|
||||
|
||||
// La sauvegarde en base de données se fait exclusivement via le bouton 'Enregistrer la personnalisation'
|
||||
}
|
||||
|
||||
@@ -13551,6 +13580,107 @@ ${vpnBadgeTopo}
|
||||
twoFaCurrInput.addEventListener('input', () => { authCurrInput.value = twoFaCurrInput.value; });
|
||||
}
|
||||
|
||||
function evaluatePasswordStrength(pwd) {
|
||||
if (!pwd) return null;
|
||||
const len = pwd.length;
|
||||
const hasLower = /[a-z]/.test(pwd);
|
||||
const hasUpper = /[A-Z]/.test(pwd);
|
||||
const hasDigit = /[0-9]/.test(pwd);
|
||||
const hasSpecial = /[^a-zA-Z0-9]/.test(pwd);
|
||||
|
||||
let score = 0;
|
||||
if (len >= 8) score++;
|
||||
if (len >= 12) score++;
|
||||
if (hasLower && hasUpper) score++;
|
||||
if (hasDigit) score++;
|
||||
if (hasSpecial) score++;
|
||||
|
||||
if (len < 8 || score <= 1) {
|
||||
return {
|
||||
tier: 'weak',
|
||||
label: t('pwd_strength_weak', 'Faible'),
|
||||
percent: 25,
|
||||
color: 'var(--red, #ef4444)'
|
||||
};
|
||||
} else if (score === 2) {
|
||||
return {
|
||||
tier: 'fair',
|
||||
label: t('pwd_strength_fair', 'Passable'),
|
||||
percent: 50,
|
||||
color: '#f59e0b'
|
||||
};
|
||||
} else if (score === 3 || score === 4) {
|
||||
return {
|
||||
tier: 'strong',
|
||||
label: t('pwd_strength_strong', 'Fort'),
|
||||
percent: 75,
|
||||
color: 'var(--green, #10b981)'
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
tier: 'extreme',
|
||||
label: t('pwd_strength_extreme', 'Extrême'),
|
||||
percent: 100,
|
||||
color: '#8b5cf6'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function updatePasswordStrengthIndicator(type) {
|
||||
const isConfirm = (type === 'confirm');
|
||||
const input = isConfirm ? $('authSettingsPasswordConfirm') : $('authSettingsPassword');
|
||||
const wrap = isConfirm ? $('pwdStrengthWrap_confirm') : $('pwdStrengthWrap_new');
|
||||
const bar = isConfirm ? $('pwdStrengthBar_confirm') : $('pwdStrengthBar_new');
|
||||
const text = isConfirm ? $('pwdStrengthText_confirm') : $('pwdStrengthText_new');
|
||||
const matchText = isConfirm ? $('pwdMatchText_confirm') : null;
|
||||
|
||||
if (!input || !wrap || !bar || !text) return;
|
||||
const val = input.value;
|
||||
if (!val) {
|
||||
wrap.style.display = 'none';
|
||||
bar.style.width = '0%';
|
||||
text.textContent = '';
|
||||
if (matchText) matchText.textContent = '';
|
||||
return;
|
||||
}
|
||||
|
||||
wrap.style.display = 'block';
|
||||
const res = evaluatePasswordStrength(val);
|
||||
bar.style.width = res.percent + '%';
|
||||
bar.style.backgroundColor = res.color;
|
||||
text.textContent = res.label;
|
||||
text.style.color = res.color;
|
||||
|
||||
if (isConfirm && matchText) {
|
||||
const mainVal = $('authSettingsPassword') ? $('authSettingsPassword').value : '';
|
||||
if (mainVal) {
|
||||
if (val === mainVal) {
|
||||
matchText.textContent = t('pwd_match_yes', '✓ Identique');
|
||||
matchText.style.color = 'var(--green, #10b981)';
|
||||
} else {
|
||||
matchText.textContent = t('pwd_match_no', '⚠️ Différent');
|
||||
matchText.style.color = 'var(--red, #ef4444)';
|
||||
}
|
||||
} else {
|
||||
matchText.textContent = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($('authSettingsPassword')) {
|
||||
$('authSettingsPassword').addEventListener('input', () => {
|
||||
updatePasswordStrengthIndicator('new');
|
||||
if ($('authSettingsPasswordConfirm') && $('authSettingsPasswordConfirm').value) {
|
||||
updatePasswordStrengthIndicator('confirm');
|
||||
}
|
||||
});
|
||||
}
|
||||
if ($('authSettingsPasswordConfirm')) {
|
||||
$('authSettingsPasswordConfirm').addEventListener('input', () => {
|
||||
updatePasswordStrengthIndicator('confirm');
|
||||
});
|
||||
}
|
||||
|
||||
$('apControl').onclick = () => controlAp(status.active ? 'stop' : 'start');
|
||||
$('apRestart').onclick = () => { if (status && status.active) controlAp('restart'); };
|
||||
|
||||
@@ -13843,6 +13973,7 @@ ${vpnBadgeTopo}
|
||||
const data = await response.json(); if (!response.ok) throw Error(data.error || 'Modification refusée');
|
||||
message.textContent = tMsg(data.message || t('auth_creds_updated_success', 'Identifiants modifiés avec succès !'));
|
||||
$('authCurrentPassword').value = ''; $('authSettingsPassword').value = ''; $('authSettingsPasswordConfirm').value = '';
|
||||
updatePasswordStrengthIndicator('new'); updatePasswordStrengthIndicator('confirm');
|
||||
if (typeof loadAdminUser === 'function') await loadAdminUser();
|
||||
} catch (e) { message.textContent = tErr(e.message); }
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user