Search code examples
springspring-social

How to avoid connecting two different webapp accounts with one social account


I'm using Spring Social to connect user application account to a social account (Facebook and/or Twitter).

It turns out that it is possible that two different user accounts connect to the same social account.

Example:

  • User1 in my webapp connects with Facebook account #1
  • User2 in my webapp connects with Facebook account #1

This is possible now. Looks like this happens inside Spring Social. After that, sign-in with social account is not possible for both accounts.

I would like to avoid connecting same social account to different webapp users at a point when User2 tries to connect. Any hint how can I do that is appreciated!


Solution

  • An answer to this question is providede here. Code example here.

    In short, ConnectInterceptor must be used for ConnectController to check for existing connection and remove currently creating connection if its a duplicate.