From 8fa6fc59ce8483c900085d8501c23143e3378c55 Mon Sep 17 00:00:00 2001 From: Mahmoud Adel Date: Fri, 21 Aug 2020 01:02:09 +0200 Subject: [PATCH 1/2] use import_callable() to correctly import classes in REST_AUTH_REGISTER_PERMISSION_CLASSES --- dj_rest_auth/registration/app_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dj_rest_auth/registration/app_settings.py b/dj_rest_auth/registration/app_settings.py index bbc7075..f0b6c62 100644 --- a/dj_rest_auth/registration/app_settings.py +++ b/dj_rest_auth/registration/app_settings.py @@ -13,5 +13,5 @@ RegisterSerializer = import_callable(serializers.get('REGISTER_SERIALIZER', Defa def register_permission_classes(): permission_classes = [AllowAny, ] for klass in getattr(settings, 'REST_AUTH_REGISTER_PERMISSION_CLASSES', tuple()): - permission_classes.append(klass) + permission_classes.append(import_callable(klass)) return tuple(permission_classes) From 7e5b3db2a1a03a48e5875a346db1037b2fed09fb Mon Sep 17 00:00:00 2001 From: Mahmoud Adel Date: Fri, 21 Aug 2020 01:30:53 +0200 Subject: [PATCH 2/2] add REST_AUTH_REGISTER_PERMISSION_CLASSES --- docs/configuration.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index 12d9ad2..5ab8156 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -41,6 +41,17 @@ Configuration - REGISTER_SERIALIZER - serializer class in ``dj_rest_auth.registration.views.RegisterView``, default value ``dj_rest_auth.registration.serializers.RegisterSerializer`` .. note:: The custom REGISTER_SERIALIZER must define a ``def save(self, request)`` method that returns a user model instance +- **REST_AUTH_REGISTER_PERMISSION_CLASSES** - A tuple contains paths of another permission classes you wish to be used in ``RegisterView``, ``AllowAny`` is included by default. + + Example : + + .. code-block:: python + + REST_AUTH_REGISTER_PERMISSION_CLASSES = ( + 'rest_framework.permissions.IsAuthenticated', + 'path.to.another.permission.class', + ... + ) - **REST_AUTH_TOKEN_MODEL** - path to model class for tokens, default value ``'rest_framework.authtoken.models.Token'`` - **REST_AUTH_TOKEN_CREATOR** - path to callable or callable for creating tokens, default value ``dj_rest_auth.utils.default_create_token``. - **REST_SESSION_LOGIN** - Enable session login in Login API view (default: True)