Merge pull request #130 from mohmyo/master

Bug fix: register_permission_classes() & add REST_AUTH_REGISTER_PERMISSION_CLASSES to docs
This commit is contained in:
Michael 2020-08-22 23:05:02 -05:00 committed by GitHub
commit d762e20418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -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)

View File

@ -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)