【发布时间】:2019-10-30 04:27:04
【问题描述】:
我的用户表上有一个用户角色列。
- 代表超级管理员,
- 代表其他用户
我查看了很多 Laravel 教程,但都没有帮助我解决这个问题。
我找到了一些方法,比如替换整个 Laravel 的 Login Controller 并用我们自己的替换 Authenticate Users trait。我想用最少的代码更改来解决我的问题。可能吗?
如何在此 Trait 方法中以最少的代码更改来实现它?
public function login(Request $request)
{
$this->validateLogin($request);
if (method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
【问题讨论】:
标签: laravel login laravel-5.8 laravel-authentication