Handling users that exist, but try to login through Facebook OAuth / etc

早过忘川 提交于 2019-12-07 07:31:17

问题


I've got a decent set of existing users on my website who login via their emailaddress as their username.

I'm setting up Facebook OAuth mechanism to allow new users to sign up more conveniently, but I'm not sure how to handle the scenario when a user who already has an email address registered with our system and now tries to login via Facebook.

  1. Should I consider him the same user?
  2. Should I treat him like a new user?

The situation is more complicated by the fact that I dont validate their email addresses (when they login directly into my system), so i cant assume they are the same user.

How do others resolve this conflict, or do other folks simply treat this user connecting via FB as a new entity?


回答1:


On your login screen, users can have a choice: you may put

  • new user: signup using facebook

since this is a totally new user account, then you just need to do your facebook connect + request for email permission, etc.

  • existing user: login by email

Once they do this, let them login using the old-fashioned way. Then once signed in, prompt them to connect this email address to their facebook account. So the flow is login via email then optional facebook connect.

To do this, I assume you've added a field on your database table for user_accounts, that is facebook_user_id or fb_id or user_id, etc. Then on facebook connect, get the logged-in-email, UPDATE table SET fb_id = xxx WHERE email = xx




回答2:


I've pondered the same issue. I think we'll go with the verified email (Facebook Connect) getting attached to and logged into the existing account with the same email.

Before we connect and log them in we'll explain that the account exist and ask for their password (they signed up using email and password, so they should know it) to ensure it's the right person.

If you support multiple external authentications (Google OAuth, Facebook etc) then you may not have a password, and in that case it gets slightly trickier.

If you do log them in to the existing account without asking for a password, make sure you clear existing sessions to avoid 'anticipation attacks', where an attacker anticipates that the target signs up, creates an account and keep the session after they've signed up and attached to the attackers existing account.



来源:https://stackoverflow.com/questions/5919747/handling-users-that-exist-but-try-to-login-through-facebook-oauth-etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!