def save(self, *args, **kwargs): """ Generates a one-use only link for resetting password and sends to the Copy of Django's implementation, changed to use our own email-sending. """ UserModel = get_user_model() email = self.cleaned_data["email"] active_users = UserModel._default_manager.filter(email__iexact=email, is_active=True) 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 uid = urlsafe_base64_encode(force_bytes(user.pk)) token = default_token_generator.make_token(user) send_password_reset(user, uid, token)
def save(self, *args, **kwargs): """ Generates a one-use only link for resetting password and sends to the Copy of Django's implementation, changed to use our own email-sending. """ UserModel = get_user_model() email = self.cleaned_data["email"] active_users = UserModel.objects.filter(email__iexact=email, is_active=True) 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 uid = urlsafe_base64_encode(force_bytes(user.pk)) token = default_token_generator.make_token(user) send_password_reset(user, uid, token)