【发布时间】:2017-11-23 00:24:11
【问题描述】:
我正在使用 Laravel 5.2
我在我的 authController.php 中修改了 postLogin() 方法。
public function postLogin(Request $request)
{
$inputs = $request->all();
$this->validateLogin($request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $lockedOut = $this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if ($inputs['email'] == 'test@test.com') {
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles && ! $lockedOut) {
$this->incrementLoginAttempts($request);
}
return $this->sendFailedLoginResponse($request);
}
现在,如果我在电子邮件表单中输入不同于 test@test.com 的内容,我会返回登录页面,并显示此用户无法识别的错误。但是,如果我使用正确的电子邮件 test@test.com,那么我可以看到它转到正确的页面(重定向有效),然后返回登录页面,就好像我没有经过身份验证一样。
我想这是因为它没有设置 cookie 或类似的东西向 Laravel 表明用户已通过身份验证。
我试图实现的是: 事实上,我想改变我的身份验证方式,并使用用户名密码向我的公司活动目录发出请求,它会给我发回真假。这样我就不需要使用本地数据库来存储密码。所以它需要首先检查电子邮件是否在本地数据库中,然后它将通过 curl 连接到我公司的 AD 并得到响应,然后我会知道用户是否输入了正确的密码。
【问题讨论】:
-
检查你的中间件是否有正确的方法来验证检查?
标签: laravel