Skip to content
Snippets Groups Projects
middleware.py 505 B
Newer Older
  • Learn to ignore specific revisions
  • from social_core.exceptions import AuthForbidden
    from social_django.middleware import SocialAuthExceptionMiddleware as _SocialAuthExceptionMiddleware
    
    class SocialAuthExceptionMiddleware(_SocialAuthExceptionMiddleware):
        """
        Wrapper around SocialAuthExceptionMiddleware to customise messages
        """
        def get_message(self, request, exception):
            if isinstance(exception, AuthForbidden):
                return 'Your credentials are not allowed'
    
            super().get_message(request, exception)