From f40c031c801cb66f1fd03a0101e8fad86ea8fc8a Mon Sep 17 00:00:00 2001 From: Philippe Luickx Date: Fri, 30 Jun 2017 23:07:50 +0300 Subject: [PATCH] check for is_open_for_signup method in the adapter on register --- rest_auth/registration/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rest_auth/registration/views.py b/rest_auth/registration/views.py index d6638b6..5b56de3 100644 --- a/rest_auth/registration/views.py +++ b/rest_auth/registration/views.py @@ -36,7 +36,14 @@ class RegisterView(CreateAPIView): @sensitive_post_parameters_m def dispatch(self, *args, **kwargs): - return super(RegisterView, self).dispatch(*args, **kwargs) + # Check if registration is open + if get_adapter(self.request).is_open_for_signup(self.request): + return super(RegisterView, self).dispatch(*args, **kwargs) + else: + return Response( + data={'message': 'Registration is not open.'}, + status=status.HTTP_403_FORBIDDEN, + ) def get_response_data(self, user): if allauth_settings.EMAIL_VERIFICATION == \