From: Vincent Vanwaelscappel Date: Fri, 21 Apr 2023 17:20:33 +0000 (+0200) Subject: wip #5873 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=90d68ed3bc35678976a4a4ac574877e19c05258b;p=cubist_cms-back.git wip #5873 @1 --- diff --git a/src/app/Magic/Models/CubistMagicAuthenticatable.php b/src/app/Magic/Models/CubistMagicAuthenticatable.php index f632d98..7dc7096 100644 --- a/src/app/Magic/Models/CubistMagicAuthenticatable.php +++ b/src/app/Magic/Models/CubistMagicAuthenticatable.php @@ -15,7 +15,6 @@ use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; use Illuminate\Foundation\Auth\Access\Authorizable; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Facades\Password; use Parental\HasParent; use Spatie\Permission\Traits\HasRoles; @@ -61,6 +60,10 @@ class CubistMagicAuthenticatable extends CubistMagicAbstractModel return parent::onSaving(); } + public function isDisabled(){ + return !$this->enabled; + } + public function setFields() { @@ -106,4 +109,6 @@ class CubistMagicAuthenticatable extends CubistMagicAbstractModel 'can' => 'users:admin' ]); } + + } diff --git a/src/app/Middleware/CheckDisabledUsers.php b/src/app/Middleware/CheckDisabledUsers.php new file mode 100644 index 0000000..531e365 --- /dev/null +++ b/src/app/Middleware/CheckDisabledUsers.php @@ -0,0 +1,25 @@ +check()) { + $user = auth()->user(); + if ($user instanceof CubistMagicAuthenticatable && $user->isDisabled()) { + Auth::logout(); + $request->session()->invalidate(); + $request->session()->regenerateToken(); + return redirect('/')->with('error', 'Unknown account'); + } + } + return $next($request); + } +} diff --git a/src/app/Providers/UserProvider.php b/src/app/Providers/UserProvider.php new file mode 100644 index 0000000..4c5b4dc --- /dev/null +++ b/src/app/Providers/UserProvider.php @@ -0,0 +1,10 @@ +