add(settings): account deletion
This commit is contained in:
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-03-19 13:37+0100\n"
|
||||
"POT-Creation-Date: 2024-03-20 10:25+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -30,6 +30,10 @@ msgstr "Le mot de passe ne correspond pas."
|
||||
msgid "You dont have permission for this user."
|
||||
msgstr "Vous n'avez pas de permissions pour cet utilisateur."
|
||||
|
||||
#: views/delete.py:19
|
||||
msgid "Password incorrect."
|
||||
msgstr "Mot de passe incorrect."
|
||||
|
||||
#: views/login.py:23
|
||||
msgid "Invalid username or password."
|
||||
msgstr "Nom d'utilisateur ou mot de passe incorect."
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user