首页 > 解决方案 > 如果用户使用 Laravel Breeze 处于活动状态,则登录

问题描述

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

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

 throw ValidationException::withMessages([
  'email' => __('auth.failed'),
 ]);
}

标签: phplaravelauthenticationlaravel-8

解决方案


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

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

推荐阅读