def save(self, domain_override=None,
             subject_template_name='registration/password_reset_subject.txt',
             email_template_name='registration/password_reset_email.html',
             # WARNING: Django 1.7 passes this in automatically. do not remove
             html_email_template_name=None,
             use_https=False, token_generator=default_token_generator,
             from_email=None, request=None):
        UserModel = get_user_model()
        email = self.cleaned_data["email"]

        # this is the line that we couldn't easily override in PasswordForm where
        # we specifically filter for the username, not the email, so that
        # mobile workers who have the same email set as a web worker don't
        # get a password reset email.
        active_users = UserModel._default_manager.filter(
            username__iexact=email, is_active=True)

        # the code below is copied from default PasswordForm
        for user in active_users:
            # Make sure that no email is sent to a user that actually has
            # a password marked as unusable
            if not user.has_usable_password():
                continue
            if not domain_override:
                current_site = get_current_site(request)
                site_name = current_site.name
                domain = current_site.domain
            else:
                site_name = domain = domain_override
            c = {
                'email': user.email,
                'domain': domain,
                'site_name': site_name,
                'uid': urlsafe_base64_encode(force_bytes(user.pk)),
                'user': user,
                'token': token_generator.make_token(user),
                'protocol': 'https' if use_https else 'http',
            }
            subject = render_to_string(subject_template_name, c)
            # Email subject *must not* contain newlines
            subject = ''.join(subject.splitlines())
            email = render_to_string(email_template_name, c)
            send_mail_async.delay(subject, email, from_email, [user.email])
Generates a one-use only link for resetting password and sends to the
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/domain/forms.py/HQPasswordResetForm.save