Php Laravel 5.1多身份验证登录
我使用并完成了所有步骤Php Laravel 5.1多身份验证登录,php,laravel,laravel-5.1,Php,Laravel,Laravel 5.1,我使用并完成了所有步骤 我注册了Register,但在登录时,如果它是admin,admin只登录,customer不Auth.php,那么它将和数组中的第一个一起输入 'multi-auth' => [ 'admin' => [ 'driver' => 'eloquent', 'model' => App\AdminModel::class ], 'customer' => [ 'drive
我注册了Register,但在登录时,如果它是admin,admin只登录,customer不Auth.php,那么它将和数组中的第一个一起输入
'multi-auth' => [
'admin' => [
'driver' => 'eloquent',
'model' => App\AdminModel::class
],
'customer' => [
'driver' => 'eloquent',
'model' => App\CustomerModel::class
]
],
postLogin()
您想问什么?当我使用第一个表管理员登录时,而不是使用客户登录时,当我使用客户登录时,它将重定向到登录页面,请按照以下步骤操作,因为laravel 5.2提供了多身份验证。。您想问什么?当我使用第一个表管理员登录时,而不是使用客户登录时,当我使用客户登录时,它将重定向到登录页面,请按照以下步骤操作,因为laravel 5.2提供了多身份验证。。
public function postLogin(Request $request)
{
$this->validate($request, [
$this->loginUsername() => 'required', 'password' => 'required',
]);
// 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 && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (Auth::admin()->attempt($credentials, $request->has('remember'))) {
return redirect('Admin');
}
if (Auth::customer()->attempt($credentials, $request->has('remember'))) {
return redirect('/');
}
// 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) {
$this->incrementLoginAttempts($request);
}
return redirect($this->loginPath())
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}