Advertisement
kastielspb

Social auth fix

Apr 9th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from django.shortcuts import redirect
  2. from django.urls import reverse_lazy
  3. from social_django.middleware import SocialAuthExceptionMiddleware
  4. from social_core.exceptions import SocialAuthBaseException
  5.  
  6.  
  7. class CustomSocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware):
  8.     def process_exception(self, request, exception):
  9.         if issubclass(exception.__class__, SocialAuthBaseException):
  10.             return redirect(reverse_lazy('staff:auth:login'))
  11.         else:
  12.             raise exception
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement