doucou19961205
2019-03-06 10:34
浏览 247
已采纳

Laravel与facebook登录

I am having troubles in logging in with Facebook.

I am using Laravel Socialite, I have followed all the instructions but I am having problems at method callback.

This is what i do :

public function redirectToFacebook()
{
    return Socialite::driver('facebook')->redirect();
}
public function handleFacebookCallback()
{
    $userSocial = Socialite::driver('facebook')->user();
    //return $userSocial;
    $finduser = User::where('facebook_id', $userSocial->id)->first();
    if($finduser){
        Auth::login($finduser);
        return Redirect::to('/');
    }else{
        $new_user = User::create([
           'name'        => $userSocial->name,
           'email'       => $userSocial->email,
           'image'       => $userSocial->avatar_original,
           'facebook_id' => $userSocial->id
        ]);
        Auth::login($new_user);
        return redirect()->back();
    }
}

SQLSTATE[HY000]: General error: 1364 Field 'password' doesn't have a default value

How to get the password of facebook?

1条回答 默认 最新

相关推荐 更多相似问题