我正在将一个纯PHP应用程序重构为Laravel。我已经对Laravel进行了身份验证。有用。但是,我需要一种将旧用户和密码迁移到新表的方法。我的想法是,在登录POST时,验证用户是否存储在旧表上,如果是,则将该用户插入新表上,然后使用laravel auth进行操作。我可以覆盖LoginController中的登录方法来进行这些更改吗?有可能吗?
我不得不重写登录方法,添加了函数migrationUserModelInternet($ request)。
受保护的函数登录(请求$ request){
$this->validateLogin($request);
$this->migrationUserModelInternet($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.
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
// 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.
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}