From e6f02ce07f158615be6f194bf2f26bab8d18acc7 Mon Sep 17 00:00:00 2001 From: miguel456 Date: Fri, 19 Aug 2022 00:52:02 +0100 Subject: [PATCH] refactor: expanded AccountStatus data --- app/View/Components/AccountStatus.php | 15 ++++++++--- .../views/components/account-status.blade.php | 26 +++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/View/Components/AccountStatus.php b/app/View/Components/AccountStatus.php index 0c6bf6f..75f2f5e 100755 --- a/app/View/Components/AccountStatus.php +++ b/app/View/Components/AccountStatus.php @@ -7,16 +7,25 @@ use Illuminate\View\Component; class AccountStatus extends Component { - public $user; + public bool $isVerified; + + public bool $isSuspended; + + public bool $isLocked; + + public bool $has2FA; /** * Create a new component instance. * * @return void */ - public function __construct($userId) + public function __construct($isVerified, $isSuspended, $isLocked, $has2FA) { - $this->user = User::findOrFail($userId); + $this->isVerified = $isVerified; + $this->isSuspended = $isSuspended; + $this->isLocked = $isLocked; + $this->has2FA = $has2FA; } /** diff --git a/resources/views/components/account-status.blade.php b/resources/views/components/account-status.blade.php index 5618a0e..9920719 100755 --- a/resources/views/components/account-status.blade.php +++ b/resources/views/components/account-status.blade.php @@ -1,23 +1,27 @@ - @if ($user->isBanned()) + @if ($isSuspended) {{__('Suspended')}} @else {{__('Active')}} @endif @if (Auth::user()->hasRole('admin')) - @if ($user->has2FA()) - {{ __('MFA Active') }} - @else - {{ __('MFA Inactive') }} - @endif + @if ($isLocked) + {{ __('Admin locked') }} + @endif - @if(!is_null($user->email_verified_at)) - {{ __('Verified Email') }} - @else - {{ __('Unverified Email') }} - @endif + @if($isVerified) + {{ __('Verified Email') }} + @else + {{ __('Unverified Email') }} + @endif + + @if ($has2FA) + {{ __('MFA Active') }} + @else + {{ __('MFA Inactive') }} + @endif @endif