From d7532b875ed77f9fda94863aa400b3d6d926a64a Mon Sep 17 00:00:00 2001 From: michaeldel Date: Thu, 26 Jul 2018 17:36:39 +0200 Subject: [PATCH] Allow dynamic callback_url and client_class class attributes --- rest_auth/registration/serializers.py | 4 ++-- rest_auth/registration/views.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index 4f99c18..a819776 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -83,8 +83,8 @@ class SocialLoginSerializer(serializers.Serializer): # Case 2: We received the authorization code elif attrs.get('code'): - self.callback_url = getattr(view, 'callback_url', None) - self.client_class = getattr(view, 'client_class', None) + self.callback_url = view.get_callback_url() + self.client_class = view.get_client_class() if not self.callback_url: raise serializers.ValidationError( diff --git a/rest_auth/registration/views.py b/rest_auth/registration/views.py index 0e0ab0d..599c230 100644 --- a/rest_auth/registration/views.py +++ b/rest_auth/registration/views.py @@ -123,6 +123,12 @@ class SocialLoginView(LoginView): """ 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): get_adapter(self.request).login(self.request, self.user)