After I create a user using say Facebook(let's say fbuser) or Google(googleuser). If I create another user through the normal django admin(normaluser), and try logging again using Facebook or Google while third user(normaluser) is logged in, it throws an error exception AuthAlreadyAssociated.
Ideally it should throw an error called you are already logged in as user normaluser.
Or it should log out normal user, and try associating with the account which is already associated with FB or Google, as the case may be.
How do I implement one of these two above features? All advice welcome.
Also when I try customizing SOCIAL_AUTH_PIPELINE, it is not possible to login with FB or Google, and it forces the login URL /accounts/login/
DSA doesn't logout accounts (or flush sessions) at the moment. AuthAlreadyAssociated
highlights the scenario where the current user is not associated to the current social account trying to be used. There are a couple solutions that might suite your project:
Define a sub-class of social_auth.middleware.SocialAuthExceptionMiddleware
and override the default behavior (process_exception()
) to redirect or setup the warning you like in the way you prefer.
Add a pipeline method (replacing social_auth.backend.pipeline.social.social_auth_user
) that logouts the current user instead of raising an exception.