ft_transcendence/accounts/views/delete.py

19 lines
604 B
Python
Raw Normal View History

from django.shortcuts import render
from django.views import View
2023-10-25 10:10:23 -04:00
from django.http import HttpResponse, HttpRequest
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from ..status_code import *
2023-10-25 10:10:23 -04:00
class DeleteView(View):
@method_decorator(login_required, name='dispatch')
2023-10-25 10:10:23 -04:00
def get(self, request: HttpRequest):
return HttpResponse(METHOD_INVALID)
@method_decorator(login_required, name='dispatch')
2023-10-25 10:10:23 -04:00
def post(self, request: HttpRequest):
request.user.delete()
return HttpResponse(USER_DELETED)