Last active
December 19, 2015 18:48
-
-
Save votaguz/6000847 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import redirect | |
from social_auth.middleware import SocialAuthExceptionMiddleware | |
from social_auth.exceptions import AuthAlreadyAssociated | |
class CustomSocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware): | |
def get_redirect_uri(self, request, exception): | |
if isinstance(exception, AuthAlreadyAssociated): | |
# Redirect this error to a custom page where the situation is | |
# explained to users | |
return redirect('/account-already-associated') | |
else: | |
return super(CustomSocialAuthExceptionMiddleware, self)\ | |
.get_redirect_uri(request, exception) | |
# Register it on settings.MIDDLEWARE_CLASSES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment