Blinkenbunt Account Manager
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.
 
 

13 lines
502 B

import hashlib
from django.contrib.auth.forms import PasswordResetForm
from bam.models import Account
class HashedEmailPasswordResetForm(PasswordResetForm):
def get_users(self, email):
hashed_email = hashlib.sha256(bytes(email, 'utf-8')).hexdigest()
accounts = Account.objects.filter(hashed_email=hashed_email)
if accounts.count() > 0:
return (a.user for a in accounts if a.user.has_usable_password())
else:
return super().get_users(email)