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