add(settings): account deletion

This commit is contained in:
AdrienLSH
2024-03-20 10:27:02 +01:00
parent d8f28f92a9
commit c8f18b71b9
4 changed files with 73 additions and 11 deletions

View File

@ -4,6 +4,7 @@ from rest_framework.response import Response
from django.contrib.auth import logout
from django.http import HttpRequest
from rest_framework.authentication import SessionAuthentication
from django.utils.translation import gettext as _
class DeleteView(APIView):
@ -15,7 +16,7 @@ class DeleteView(APIView):
password: str = data["password"]
if (request.user.check_password(password) is False):
return Response({"password": ["Password incorrect."]},
return Response({"password": _("Password incorrect.")},
status.HTTP_401_UNAUTHORIZED)
request.user.delete()
logout(request)