Laravel 5 - 无需密码即可手动登录用户

Omi*_*mid 5 authentication oauth laravel laravel-5

我想在使用OAuth和Google帐户对用户进行身份验证后登录用户,而无需输入任何密码.

我知道Auth::loginfuncton可以做这样的动作,但我不知道如何在尚未经过身份验证的情况下获取用户实例.

有没有办法做到这一点?

ale*_*ell 14

您可以通过两种不同的方式"手动"登录用户:

// log user in by ID
Auth::loginUsingId([id of user]);
Run Code Online (Sandbox Code Playgroud)

要么

$user = User::find([id here]);
// or maybe
$user = User::whereUsername([username here])->first();

// and then
Auth::login($user);
Run Code Online (Sandbox Code Playgroud)

认证文件.