dongquweng5152 2017-02-04 06:06
浏览 80
已采纳

使用基本身份验证整合Laravel Socialite facebook登录

Already I have integrated the Laravel default Auth in my application now I want to integrate social logins with it.

Here is the work flow

1.get user details(social_id,name,email,profile_pic) from socialite

2.check the user existence with email ,if its exists execute auth::login, otherwise create a new record in users table and redirect to profile.

When a user remove email-id during Facebook auth Approval page I will get

$user-getEmail() as null so in this case above workflow is not applicable since everything is depend on user email so how can I handle this situation

  • 写回答

1条回答 默认 最新

  • dongwo8827523 2017-02-04 06:45
    关注

    since everything is depend on user email

    Well that's the problem. You need to be able to handle Facebook users without email addresses. So on login, instead of checking for users' existence based on email, check:

    • If the provider is Facebook, check based on User->getId()
    • Otherwise, check based on email

    See this tutorial for some further code samples.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?