mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-11-25 10:33:45 +03:00
Merge pull request #312 from swstack/custom-registration-permissions
Custom registration permissions
This commit is contained in:
commit
e665b95643
3
dev-requirements.txt
Normal file
3
dev-requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
--editable .
|
||||||
|
responses>=0.5.0
|
||||||
|
djangorestframework-jwt
|
|
@ -1,5 +1,6 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
from rest_auth.registration.serializers import (
|
from rest_auth.registration.serializers import (
|
||||||
RegisterSerializer as DefaultRegisterSerializer)
|
RegisterSerializer as DefaultRegisterSerializer)
|
||||||
from ..utils import import_callable
|
from ..utils import import_callable
|
||||||
|
@ -9,3 +10,10 @@ serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {})
|
||||||
|
|
||||||
RegisterSerializer = import_callable(
|
RegisterSerializer = import_callable(
|
||||||
serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer))
|
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)
|
||||||
|
|
|
@ -22,7 +22,7 @@ from rest_auth.registration.serializers import (SocialLoginSerializer,
|
||||||
VerifyEmailSerializer)
|
VerifyEmailSerializer)
|
||||||
from rest_auth.utils import jwt_encode
|
from rest_auth.utils import jwt_encode
|
||||||
from rest_auth.views import LoginView
|
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_m = method_decorator(
|
||||||
sensitive_post_parameters('password1', 'password2')
|
sensitive_post_parameters('password1', 'password2')
|
||||||
|
@ -31,7 +31,7 @@ sensitive_post_parameters_m = method_decorator(
|
||||||
|
|
||||||
class RegisterView(CreateAPIView):
|
class RegisterView(CreateAPIView):
|
||||||
serializer_class = RegisterSerializer
|
serializer_class = RegisterSerializer
|
||||||
permission_classes = (AllowAny, )
|
permission_classes = register_permission_classes()
|
||||||
token_model = TokenModel
|
token_model = TokenModel
|
||||||
|
|
||||||
@sensitive_post_parameters_m
|
@sensitive_post_parameters_m
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -31,6 +31,7 @@ setup(
|
||||||
'Django>=1.8.0',
|
'Django>=1.8.0',
|
||||||
'djangorestframework>=3.1.0',
|
'djangorestframework>=3.1.0',
|
||||||
'six>=1.9.0',
|
'six>=1.9.0',
|
||||||
|
'django-allauth>=0.25.0',
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'with_social': ['django-allauth>=0.25.0'],
|
'with_social': ['django-allauth>=0.25.0'],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user