diff --git a/rest_auth/registration/app_settings.py b/rest_auth/registration/app_settings.py index 227b45b..68c3a78 100644 --- a/rest_auth/registration/app_settings.py +++ b/rest_auth/registration/app_settings.py @@ -1,5 +1,6 @@ from django.conf import settings +from rest_framework.permissions import AllowAny from rest_auth.registration.serializers import ( RegisterSerializer as DefaultRegisterSerializer) from ..utils import import_callable @@ -9,3 +10,10 @@ serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {}) RegisterSerializer = import_callable( serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer)) + + +def register_permission_classes(): + permission_classes = [AllowAny, ] + for klass in getattr(settings, 'REST_AUTH_REGISTER_PERMISSION_CLASSES', tuple()): + permission_classes.append(import_callable(klass)) + return tuple(permission_classes) diff --git a/rest_auth/registration/views.py b/rest_auth/registration/views.py index e35153d..d6638b6 100644 --- a/rest_auth/registration/views.py +++ b/rest_auth/registration/views.py @@ -22,7 +22,7 @@ from rest_auth.registration.serializers import (SocialLoginSerializer, VerifyEmailSerializer) from rest_auth.utils import jwt_encode from rest_auth.views import LoginView -from .app_settings import RegisterSerializer +from .app_settings import RegisterSerializer, register_permission_classes sensitive_post_parameters_m = method_decorator( sensitive_post_parameters('password1', 'password2') @@ -31,7 +31,7 @@ sensitive_post_parameters_m = method_decorator( class RegisterView(CreateAPIView): serializer_class = RegisterSerializer - permission_classes = (AllowAny, ) + permission_classes = register_permission_classes() token_model = TokenModel @sensitive_post_parameters_m