test
This commit is contained in:
parent
667a0035c6
commit
707d70888b
@ -8,7 +8,6 @@ from datetime import timedelta
|
|||||||
from .models import Invitation, User
|
from .models import Invitation, User
|
||||||
from .serializers import UserSerializer, RegisterSerializer
|
from .serializers import UserSerializer, RegisterSerializer
|
||||||
from django.contrib.auth import password_validation
|
from django.contrib.auth import password_validation
|
||||||
|
|
||||||
class RegisterView(generics.CreateAPIView):
|
class RegisterView(generics.CreateAPIView):
|
||||||
queryset = User.objects.all()
|
queryset = User.objects.all()
|
||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
@ -85,13 +84,13 @@ class ChangePasswordView(APIView):
|
|||||||
if not request.user.check_password(current_password):
|
if not request.user.check_password(current_password):
|
||||||
return Response(
|
return Response(
|
||||||
{"current_password": ["Mot de passe actuel incorrect."]},
|
{"current_password": ["Mot de passe actuel incorrect."]},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
if new_password != confirm_password:
|
if new_password != confirm_password:
|
||||||
return Response(
|
return Response(
|
||||||
{"confirm_password": ["Les mots de passe ne correspondent pas."]},
|
{"confirm_password": ["Les mots de passe ne correspondent pas."]},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -99,10 +98,10 @@ class ChangePasswordView(APIView):
|
|||||||
new_password,
|
new_password,
|
||||||
user=request.user,
|
user=request.user,
|
||||||
)
|
)
|
||||||
except DjangoValidationError as error:
|
except ValidationError as error:
|
||||||
return Response(
|
return Response(
|
||||||
{"new_password": error.messages},
|
{"new_password": error.messages},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
request.user.set_password(new_password)
|
request.user.set_password(new_password)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user