{{-- Carte « Sécurité du compte » — réutilisée pour les commerçants et les managers. Paramètres : - $partner : App\Models\Partner - $subject : App\Models\User (commerçant ou manager) - $subjectKey : 'user' | 'manager' (clé route + clé include modales) - $abilityPrefix : 'partner_users' | 'partner_managers' - $modalsPartial : nom de la vue contenant les modales déjà câblées - $activeTrustedDevicesCount : int - $activeSessionsCount : int|null (null si SESSION_DRIVER != database) - $sessionDriver : string - $wrapInCard : bool (default true) — rendre le wrapper card+header. À passer false quand la carte est intégrée dans un tab-pane. --}} @php $twoFactorStatus = $subject->twoFactorStatusFor($partner); $hasSecret = ! is_null($subject->two_factor_confirmed_at); $isLocked = $subject->password_locked_at !== null; $sessionsAvailable = $activeSessionsCount !== null; $failedAttempts = (int) ($subject->password_failed_attempts ?? 0); $twoFactorLockout = $subject->twoFactorLockout; $twoFactorLocked = $twoFactorLockout?->locked_until?->isFuture() ?? false; $twoFactorFailedAttempts = (int) ($twoFactorLockout?->failed_attempts_24h ?? 0); $wrapInCard = $wrapInCard ?? true; @endphp @if($wrapInCard)
{{ __('security.section.title') }}
@endif {{-- 1. ÉTAT DE LA DOUBLE AUTHENTIFICATION --}}
{{ __('security.section.two_factor') }}
{{ $twoFactorStatus->label() }} @if($help = $twoFactorStatus->helperText()) {{ $help }} @endif
@if($subject->two_factor_confirmed_at)
{{ __('security.two_factor.configured_at') }}
{{ $subject->two_factor_confirmed_at->format('d/m/Y à H:i') }}
@endif @if($subject->two_factor_reset_at)
{{ __('security.two_factor.last_reset') }}
{{ $subject->two_factor_reset_at->format('d/m/Y à H:i') }} ({{ $subject->two_factor_reset_at->diffForHumans() }})
@endif @if(! $subject->two_factor_confirmed_at && ! $subject->two_factor_reset_at)
{{ __('security.two_factor.configuration') }}
{{ __('security.two_factor.never_configured') }}
@endif

{{-- 2. APPAREILS & SESSIONS --}}
{{ __('security.section.devices_sessions') }}
@can($abilityPrefix . '.revoke_trusted_devices', $subject)
{{ trans_choice('security.devices.active', $activeTrustedDevicesCount, ['count' => $activeTrustedDevicesCount]) }} @if($activeTrustedDevicesCount > 0) @else {{ __('security.devices.nothing_to_revoke') }} @endif
@endcan @can($abilityPrefix . '.revoke_sessions', $subject)
@if($sessionsAvailable) {{ trans_choice('security.sessions.active', $activeSessionsCount, ['count' => $activeSessionsCount]) }} @else {{ __('security.sessions.unavailable') }} @endif @if($sessionsAvailable && $activeSessionsCount > 0) @elseif(! $sessionsAvailable) {{ __('security.sessions.driver_warning', ['driver' => $sessionDriver]) }} @else {{ __('security.sessions.nothing_to_revoke') }} @endif
@endcan
@can($abilityPrefix . '.unlock_account', $subject)
{{-- 3. VERROUILLAGE DU COMPTE --}}
{{ __('security.section.account_lock') }}
@if($isLocked)
{{ __('security.account.locked_at', ['date' => $subject->password_locked_at->format('d/m/Y H:i')]) }} {{ trans_choice('security.account.failed_attempts', $failedAttempts, ['count' => $failedAttempts]) }}
@else

{{ __('security.account.healthy') }} @if($failedAttempts > 0) ({{ trans_choice('security.account.failed_attempts', $failedAttempts, ['count' => $failedAttempts]) }}) @endif

@endif
@endcan @can($abilityPrefix . '.unlock_2fa', $subject)
{{-- 3b. VERROUILLAGE 2FA --}}
{{ __('security.section.two_factor_lockout') }}
@if($twoFactorLocked)
{{ __('security.two_factor_lockout.locked_until', ['date' => $twoFactorLockout->locked_until->format('d/m/Y H:i')]) }} {{ trans_choice('security.two_factor_lockout.failed_attempts', $twoFactorFailedAttempts, ['count' => $twoFactorFailedAttempts]) }}
@else

{{ __('security.two_factor_lockout.healthy') }} @if($twoFactorFailedAttempts > 0) ({{ trans_choice('security.two_factor_lockout.failed_attempts', $twoFactorFailedAttempts, ['count' => $twoFactorFailedAttempts]) }}) @endif

@endif
@endcan @can($abilityPrefix . '.reset_2fa', $subject) @if($hasSecret)
{{-- 4. ZONE À RISQUE — RESET 2FA --}}
{{ __('security.section.danger_zone') }}

{{ __('security.section.reset_2fa_help') }}

@endif @endcan @if($wrapInCard)
@endif @include($modalsPartial, ['partner' => $partner, $subjectKey => $subject])