Compare commits

..

No commits in common. "a17fa078050119a22a2a772aacf41db5365ce525" and "cb010470a9a6347b8d9efef245a8f9693862dd6e" have entirely different histories.

3 changed files with 2 additions and 61 deletions

View File

@ -1,8 +0,0 @@
<html>
<form method='post'>
{% csrf_token %}
<input type="text" name="username" placeholder="username">
<input type="text" name="password" placeholder="password">
<input type='submit'>
</form>
</html>

View File

@ -1,8 +0,0 @@
<html>
<form method='post'>
{% csrf_token %}
<input type="text" name="username" placeholder="username">
<input type="text" name="password" placeholder="password">
<input type='submit'>
</form>
</html>

View File

@ -4,30 +4,9 @@ from django.views import View
# Create your views here.
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.db.models.query import QuerySet
class Login(View):
def get(self, request):
return render(request, "login.html")
def post(self, request):
username = request.POST.get("username")
if (username == None):
return HttpResponse("error: username or password invalid")
password = request.POST.get("password")
if (password == None):
return HttpResponse("error: username or password invalid")
query: QuerySet = User.objects.filter(username=username)
if (not query.exists()):
return HttpResponse("error: username or password invalid")
user: User = User.objects.get(username=username)
if (not user.check_password(password)):
return HttpResponse("error: username or password invalid")
return HttpResponse("ok: account valid")
pass
class Register(View):
def get(self, request):
@ -50,26 +29,4 @@ class Register(View):
return HttpResponse("ok: user added")
class Delete(View):
def get(self, request):
return render(request, "delete.html")
def post(self, request):
username = request.POST.get("username")
if (username == None):
return HttpResponse("error: username or password invalid")
password = request.POST.get("password")
if (password == None):
return HttpResponse("error: username or password invalid")
query: QuerySet = User.objects.filter(username=username)
if (not query.exists()):
return HttpResponse("error: username or password invalid")
user: User = User.objects.get(username=username)
if (not user.check_password(password)):
return HttpResponse("error: username or password invalid")
user.delete()
return HttpResponse("ok: account has been deleted")
pass