Allow dynamic callback_url and client_class class attributes

This commit is contained in:
michaeldel 2018-07-26 17:36:39 +02:00
parent 95fafe5e0f
commit d7532b875e
2 changed files with 8 additions and 2 deletions

View File

@ -83,8 +83,8 @@ class SocialLoginSerializer(serializers.Serializer):
# Case 2: We received the authorization code # Case 2: We received the authorization code
elif attrs.get('code'): elif attrs.get('code'):
self.callback_url = getattr(view, 'callback_url', None) self.callback_url = view.get_callback_url()
self.client_class = getattr(view, 'client_class', None) self.client_class = view.get_client_class()
if not self.callback_url: if not self.callback_url:
raise serializers.ValidationError( raise serializers.ValidationError(

View File

@ -123,6 +123,12 @@ class SocialLoginView(LoginView):
""" """
serializer_class = SocialLoginSerializer serializer_class = SocialLoginSerializer
def get_callback_url(self):
return getattr(self, 'callback_url', None)
def get_client_class(self):
return getattr(self, 'client_class', None)
def process_login(self): def process_login(self):
get_adapter(self.request).login(self.request, self.user) get_adapter(self.request).login(self.request, self.user)