有没有一种方法可以自定义 laravel 身份验证以验证用户是否以前存储在旧的 table 中?
Is there a way to customize laravel auth in order to verify if a user is previally stored in a old table?
我正在将纯 PHP 应用程序重构为 Laravel。我已经进行了 Laravel 授权。有用。但是,我需要一种将旧用户和密码迁移到新 table 的方法。我的想法是,在登录 POST 时,验证用户是否存储在旧 table 上,如果是,则将该用户插入新 table 并继续 laravel 身份验证。我可以覆盖 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);
}
我正在将纯 PHP 应用程序重构为 Laravel。我已经进行了 Laravel 授权。有用。但是,我需要一种将旧用户和密码迁移到新 table 的方法。我的想法是,在登录 POST 时,验证用户是否存储在旧 table 上,如果是,则将该用户插入新 table 并继续 laravel 身份验证。我可以覆盖 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);
}