如果用户使用 Laravel Breeze 处于活动状态则登录

Khe*_*dju 0 php authentication laravel laravel-8

我已经在 LoginRequest.php 文件中的身份验证功能中更改了它,但它不起作用。

if (! Auth::attempt($this->only('email', 'password', ['active' => 1]), $this->filled('remember'))) {
 RateLimiter::hit($this->throttleKey());

 throw ValidationException::withMessages([
  'email' => __('auth.failed'),
 ]);
}
Run Code Online (Sandbox Code Playgroud)

lag*_*box 9

active部分需要添加到传递给 的数组中attempt,该数组需要与从 返回的数组合并only

Auth::attempt($this->only('email', 'password') + ['active' => 1]) ...
Run Code Online (Sandbox Code Playgroud)