/** * ========================================================================= * PLATEFORME ECO-PANNEAU.FR - VERSION 1.0.0 * Paramètres du compte client - Sous-onglet : Sécurité et 2FA * ========================================================================= */ const FallbackNull = () => null; const FallbackCardGrid = ({children, className}) => (
{children}
); const FallbackTextLogo = ({ className = "" }) => eco-panneau.fr; window.pano_ClientSettingsSecurity = ({ myClientData, showToast, refreshData, openLocalDialog, closeCurrentLayer, activeDialog }) => { const { useState } = React; const [isSaving, setIsSaving] = useState(false); const [passwordData, setPasswordData] = useState({ current: '', new: '', confirm: '' }); const [twoFactorSetup, setTwoFactorSetup] = useState(null); const [twoFactorCode, setTwoFactorCode] = useState(''); const [twoFactorSecret, setTwoFactorSecret] = useState(''); const [twoFactorQr, setTwoFactorQr] = useState(''); const [confirmConfig, setConfirmConfig] = useState(null); const { LockIcon, ShieldCheckIcon, ShieldAlertIcon, QrCodeIcon, MailIcon, CopyIcon } = window.pano_getIcons(); const FormInput = window.pano_FormInput || FallbackNull; const NativeQRCode = window.pano_NativeQRCode || FallbackNull; const Button = window.pano_Button || FallbackNull; const ConfirmModal = window.pano_ConfirmModal || FallbackNull; const TextLogo = window.pano_TextLogo || FallbackTextLogo; const CardGrid = window.pano_CardGrid || FallbackCardGrid; const handlePasswordChange = async (e) => { e.preventDefault(); if (passwordData.new !== passwordData.confirm) { showToast("Les nouveaux mots de passe ne correspondent pas.", "error"); return; } if (passwordData.new.length < 8) { showToast("Le mot de passe doit contenir au moins 8 caractères.", "error"); return; } const d = await window.pano_apiFetch('clients/password/update', { body: { oldPassword: passwordData.current, password: passwordData.new }, setLoading: setIsSaving, successMessage: "Mot de passe mis à jour." }); if (d) setPasswordData({ current: '', new: '', confirm: '' }); }; const start2FASetup = async (type) => { if (type === 'email') { setTwoFactorSetup('email'); return; } const d = await window.pano_apiFetch('clients/profile/setup_totp', { setLoading: setIsSaving }); if (d) { setTwoFactorSecret(d.data.secret); setTwoFactorQr(d.data.otpauth); setTwoFactorSetup('authenticator'); } }; const confirm2FASetup = async (e) => { e.preventDefault(); if (twoFactorSetup === 'authenticator' && twoFactorCode.length !== 6) return; const method = twoFactorSetup === 'authenticator' ? 'totp' : 'email'; const d = await window.pano_apiFetch('clients/profile/update_2fa', { body: { method: method }, setLoading: setIsSaving, successMessage: "Authentification à double facteur activée !" }); if (d) { setTwoFactorSetup(null); setTwoFactorCode(''); refreshData(); } }; const disable2FA = () => { setConfirmConfig({ title: "Désactiver la 2FA", message: "Êtes-vous sûr de vouloir désactiver l'authentification à double facteur ? Votre compte sera beaucoup moins sécurisé en cas de vol de mot de passe.", confirmText: "Oui, désactiver", cancelText: "Annuler", isDestructive: true, onConfirm: async () => { closeCurrentLayer(); const d = await window.pano_apiFetch('clients/profile/update_2fa', { body: { method: 'none' }, setLoading: setIsSaving, successMessage: "Authentification à double facteur désactivée." }); if (d) refreshData(); } }); openLocalDialog('confirm_security'); }; const handleCancel2FA = () => { setTwoFactorSetup(null); setTwoFactorCode(''); setTwoFactorSecret(''); setTwoFactorQr(''); }; return (

Modifier le mot de passe

setPasswordData({...passwordData, current: e.target.value})} required /> setPasswordData({...passwordData, new: e.target.value})} required /> setPasswordData({...passwordData, confirm: e.target.value})} required />

Authentification à double facteur

Sécurisez l'accès à vos panneaux et à votre coffre-fort légal sur .

{myClientData.twoFactorEnabled && ( Activé )}
{myClientData.twoFactorEnabled ? (

Votre compte est protégé par la double authentification. Vous devez saisir un code unique à chaque connexion depuis un nouvel appareil.

) : (
{!twoFactorSetup ? (
start2FASetup('authenticator')}>

Application (recommandé)

Utilisez Google Authenticator ou Authy pour générer des codes hors-ligne.

start2FASetup('email')}>

Par e-mail

Recevez un code de sécurité par e-mail à chaque connexion.

) : (

Configuration {twoFactorSetup === 'email' ? 'par e-mail' : 'via application'}

{twoFactorSetup === 'authenticator' && (

Scannez ce QR Code avec votre application d'authentification :

{NativeQRCode ? : }

Ou saisissez la clé manuellement :

)} {twoFactorSetup === 'email' && (

Vous allez recevoir un code de vérification à l'adresse e-mail de votre compte pour chaque connexion.

)} {twoFactorSetup === 'authenticator' && (
setTwoFactorCode(e.target.value.replace(/[^0-9]/g, '').slice(0,6))} placeholder="000000" className="w-full border-2 border-slate-200 rounded-xl p-3 focus:border-blue-500 outline-none transition font-black text-center text-xl tracking-[0.5em]" />
)}
)}
)}
{activeDialog === 'confirm_security' && confirmConfig && ConfirmModal && ( { setConfirmConfig(null); closeCurrentLayer(); }} zIndex="z-[350]" /> )}
); }; /* EOF ========== [_react/_clients_settings_security.jsx] */