Website to manage tibia accounts and characters
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

forms.py 603B

1234567891011121314151617181920
  1. from django import forms
  2. from accounts.models import Accounts
  3. from accounts.utils import LoginHelper
  4. class LoginForm(forms.Form):
  5. account_name = forms.CharField()
  6. password = forms.CharField(widget=forms.PasswordInput)
  7. def is_valid(self):
  8. if not super(LoginForm, self).is_valid():
  9. return False
  10. account = Accounts.objects.get(name=self.cleaned_data['account_name'])
  11. hashed_password = LoginHelper.hash_password(self.cleaned_data['password'])
  12. if account.password == hashed_password:
  13. return True
  14. else:
  15. return False