我是Laravel和firebase的新手,我自己做了登录和密码验证,但是我想使用Route::group(['middleware' => ['auth']])函数来保护对系统的未经授权的访问,但是我不知道如何告诉Laravel用户已经通过了身份验证而没有使用Auth::attempt($credentials)。
那么,我如何设置用户已经通过身份验证,将用户重定向到主页,将登录名(用户名称)传递给Auth。
if (Auth::attempt($credentials)) { //I need to replace this line setting the user is logged already
return redirect()->route('home');
}我试过:Auth()->login($nickname);
但我收到了:
传递给照明\Auth\SessionGuard::login()的参数1必须是照明\Contracts\Auth\Authenticatable的实例,字符串给定
发布于 2019-04-06 13:49:26
Auth()->login($user);如果是正确的方法,则应该传递$user对象,而不是包含用户昵称的字符串,例如:
$use = new User();
$user->id = 1;
$user->email = 'eshtiaghi.amin@gmail.com';
$user->name = $nickname;
$user->save();
\Auth::login($user);https://stackoverflow.com/questions/55549557
复制相似问题