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.
18 lines
687 B
18 lines
687 B
import hashlib |
|
from django.contrib.auth.forms import PasswordResetForm |
|
from django.contrib.auth.hashers import check_password |
|
from django import forms |
|
from django.utils.translation import gettext, gettext_lazy as _ |
|
from .models import Account |
|
|
|
|
|
class HashedEmailPasswordResetForm(PasswordResetForm): |
|
username = forms.CharField(label=_('Username'), max_length=254) |
|
|
|
def get_users(self, email): |
|
accounts = Account.objects.filter( |
|
user__username=self.cleaned_data['username'] |
|
) |
|
return (a.user for a in accounts if a.user.has_usable_password() and |
|
(check_password(email, a.hashed_email) |
|
or a.user.email == email))
|
|
|