fix: update documentation and fix smaller issues (#1520)

This commit is contained in:
Markos Gogoulos
2026-05-13 21:14:02 +03:00
committed by GitHub
parent c7a1d60d73
commit d6a11514e5
15 changed files with 34 additions and 273 deletions
+8
View File
@@ -1,5 +1,7 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.password_validation import validate_password
from django.core.exceptions import ValidationError as DjangoValidationError
from django.core.mail import EmailMessage
from django.db.models import Q
from django.http import HttpResponseRedirect
@@ -369,9 +371,15 @@ class UserDetail(APIView):
if action == "change_password":
# Permission to edit user is already checked by self.get_user -> self.check_object_permissions
if user.is_superuser and not request.user.is_superuser:
raise PermissionDenied("You do not have permission to change a superuser's password.")
password = request.data.get("password")
if not password:
return Response({"detail": "Password is required"}, status=status.HTTP_400_BAD_REQUEST)
try:
validate_password(password, user=user)
except DjangoValidationError as exc:
return Response({"detail": list(exc.messages)}, status=status.HTTP_400_BAD_REQUEST)
user.set_password(password)
user.save()