Home > Back-end >  What should happen if a user sign up via social login and then tries to register with same mail?
What should happen if a user sign up via social login and then tries to register with same mail?

Time:03-16

In my Spring Boot I'd like to have both social login and signup with user and password.

Let's say the user signs-up via Google. After some time, he forgets that he signed-in via Google and tried to register using the same email.

What should happen in this case? Should I save user info (returned by Google) in a "users" table of my database to prevent the same user to register twice? Is there an article or something that explains a similar login/registration flow?

CodePudding user response:

you can save all the users(OAuth or signup) in the user table. you can maintain a column by which you will be able to identify them if a user is signed in via OAuth or email. then if a user tries to signup via the same email you can show a message. or you can design your signup process using multiple steps. at first, the user needs to enter her email address, then you can send her an email where she needs to click some link that has some token in the url, if she previously logged in using some oath provider then she will be automatically logged in otherwise she needs to set her password.

CodePudding user response:

I answer to myself. I've this article that explains what I'd like to do. https://www.callicoder.com/spring-boot-security-oauth2-social-login-part-1/

It follows more or less the advice of Tanmoy.

  • Related