我是 Laravel 的新手,并且在实现用户身份验证方面相当成功。现在继续下一步,我必须只允许状态为事件的用户登录。为此,我添加了一个
status TINYINT
我的 mysql 用户表中的列。
我在 Laravel 文档中找到了这个:
Specifying Additional Conditions
If you wish, you may also add extra conditions to the authentication query in addition to the user's e-mail and password. For example, we may verify that user is marked as "active":
if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1])) { // The user is active, not suspended, and exists. }
有人可以指出我需要把这个 block 放在哪里吗?我很困惑,需要一些指导。
谢谢
最佳答案
在你的 LoginController 上有这个:
protected function credentials(Request $request)
{
return ['username' => $request->{$this->username()}, 'password' => $request->password, 'status' => 1];
}
关于php - 仅当用户在 Laravel 5.7 中处于事件状态时才登录用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53780787/