@@ -4,7 +4,9 @@ namespace App\Providers;
|
||||
|
||||
use App\Actions\Fortify\CreateNewUser;
|
||||
use App\Actions\Fortify\ResetUserPassword;
|
||||
use App\Http\Responses\RegisterResponse;
|
||||
use App\Models\User;
|
||||
use App\Services\LicenseEntitlementService;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -13,6 +15,7 @@ use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
use Inertia\Inertia;
|
||||
use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract;
|
||||
use Laravel\Fortify\Features;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
@@ -23,7 +26,7 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
$this->app->singleton(RegisterResponseContract::class, RegisterResponse::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +47,9 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
Fortify::authenticateUsing(function (Request $request): ?User {
|
||||
$user = User::query()->withoutGlobalScope('tenant')->where('email', $request->string('email'))->first();
|
||||
|
||||
return $user && $user->is_active && Hash::check($request->string('password'), $user->password)
|
||||
$licenseValid = ! $user || $user->is_platform_admin || app(LicenseEntitlementService::class)->allowsUse($user->tenant_id);
|
||||
|
||||
return $user && $user->is_active && $licenseValid && Hash::check($request->string('password'), $user->password)
|
||||
? $user
|
||||
: null;
|
||||
});
|
||||
@@ -60,9 +65,14 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
{
|
||||
Fortify::loginView(fn (Request $request) => Inertia::render('auth/login', [
|
||||
'canResetPassword' => Features::enabled(Features::resetPasswords()),
|
||||
'canRegister' => Features::enabled(Features::registration()),
|
||||
'status' => $request->session()->get('status'),
|
||||
]));
|
||||
|
||||
Fortify::registerView(fn () => Inertia::render('auth/register', [
|
||||
'passwordRules' => Password::defaults()->toPasswordRulesString(),
|
||||
]));
|
||||
|
||||
Fortify::resetPasswordView(fn (Request $request) => Inertia::render('auth/reset-password', [
|
||||
'email' => $request->email,
|
||||
'token' => $request->route('token'),
|
||||
|
||||
Reference in New Issue
Block a user