From cd8e918890f76802ceb7c7da069e5524a72ac60f Mon Sep 17 00:00:00 2001 From: Gesche Gierse Date: Sun, 20 Jan 2019 22:24:01 +0100 Subject: [PATCH] add index and login page (not yet good) --- accounts/forms.py | 20 ++++++++++++++++++++ accounts/templates/index.html | 17 +++++++++++++---- accounts/templates/login.html | 17 +++++++++++++++++ accounts/urls.py | 1 + accounts/utils.py | 9 +++++++++ accounts/views.py | 14 ++++++++++---- 6 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 accounts/forms.py create mode 100644 accounts/templates/login.html create mode 100644 accounts/utils.py diff --git a/accounts/forms.py b/accounts/forms.py new file mode 100644 index 0000000..114fd9c --- /dev/null +++ b/accounts/forms.py @@ -0,0 +1,20 @@ +from django import forms + +from accounts.models import Accounts +from accounts.utils import LoginHelper + + +class LoginForm(forms.Form): + account_name = forms.CharField() + password = forms.CharField(widget=forms.PasswordInput) + + def is_valid(self): + if not super(LoginForm, self).is_valid(): + return False + + account = Accounts.objects.get(name=self.cleaned_data['account_name']) + hashed_password = LoginHelper.hash_password(self.cleaned_data['password']) + if account.password == hashed_password: + return True + else: + return False diff --git a/accounts/templates/index.html b/accounts/templates/index.html index 8c4686a..027a773 100644 --- a/accounts/templates/index.html +++ b/accounts/templates/index.html @@ -5,18 +5,27 @@ Highscore +

Highscore

{% if best_players %} -