fix: django connection settings (#1529)

This commit is contained in:
Markos Gogoulos
2026-05-19 21:34:18 +03:00
committed by GitHub
parent 7a02d25d0b
commit e89c4a3c85
8 changed files with 64 additions and 10 deletions
+6
View File
@@ -1,3 +1,4 @@
from allauth.account.adapter import get_adapter
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.password_validation import validate_password
@@ -277,6 +278,11 @@ class UserList(APIView):
if not all([username, password, email, name]):
return Response({"detail": "username, password, email, and name are required."}, status=status.HTTP_400_BAD_REQUEST)
try:
username = get_adapter().clean_username(username, shallow=True)
except DjangoValidationError as e:
return Response({"detail": e.messages[0]}, status=status.HTTP_400_BAD_REQUEST)
if User.objects.filter(username=username).exists():
return Response({"detail": "A user with that username already exists."}, status=status.HTTP_400_BAD_REQUEST)