Laravel 4 Auth with Facebook (no password authentication)

后端 未结 2 1272
死守一世寂寞
死守一世寂寞 2021-01-22 18:47

I\'m trying to set up an authentication system with Laravel 4 with a Facebook login. I am using the madewithlove/laravel-oauth2 package for Laravel 4.

Of course, ther

2条回答
  •  遥遥无期
    2021-01-22 19:49

    To login any user into the system, you need to use the User model, and I bet inherited classes will do the trick as well but I'm not sure.

    Anyway, your Fan model does not associate with the User model/table in any way and that's a problem. If your model had a belong_to or has_one relationship and a user_id field then you could replace Auth::login($user) with Auth::loginUsingId().


    Original answer:

    You are missing an extra method call: ->get() or ->first() to actually retrieve the results:

    $fan = Fan::where('fbid', '=', $user['uid'])->first();
    

    Alternatively, you can throw an exception to see what's going on:

    $fan = Fan::where('fbid', '=', $user['uid'])->firstOrFail();
    

    If you see different errors, update your question with those errors.

提交回复
热议问题