user disabled_at field addedù

This commit is contained in:
Giuseppe Naponiello
2026-06-24 17:02:11 +02:00
parent 96b0dc76aa
commit f8206b5840
5 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Actions\Fortify;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Laravel\Fortify\Fortify;
/**
* Login custom: oltre a verificare le credenziali, blocca gli utenti con
* `disabled_at` impostato (es. legacy `is_active=false`). I soft-deleted sono
* già esclusi dalla query di default (scope SoftDeletes sul model User), non
* serve un controllo esplicito.
*
* Registrata via `Fortify::authenticateUsing()`: viene consultata sia dal
* pre-check 2FA (`RedirectIfTwoFactorAuthenticatable`) sia dal fallback
* (`AttemptToAuthenticate`), quindi un solo punto di applicazione del gate.
*/
class AuthenticateUser
{
public function __invoke(Request $request): ?User
{
$user = User::where(Fortify::username(), $request->input(Fortify::username()))->first();
if (! $user || ! Hash::check((string) $request->input('password'), $user->password)) {
return null;
}
return $user->disabled_at === null ? $user : null;
}
}