def gen_reset_password_token(self, user=None, send_email=None):
        """Generates a reset password token and optionnaly (default to yes) send the reset
        password email
        """
        if not user and "form" in current_context.data and request.method == "POST":
            form = current_context.data.form
            user = self.find_by_email(form[self.options["email_column"]].data)
            if user is None:
                if self.options["reset_password_token_error_message"]:
                    flash(self.options["reset_password_token_error_message"], "error")
                current_context.exit(trigger_action_group="reset_password_failed")
                
        if not user:
            raise InvalidOptionError("Invalid user in 'reset_password_token' action")

        token = self._gen_reset_password_token(user)
        self.reset_password_token_signal.send(self, user=user, token=token)
        if (send_email is None and self.options["send_reset_password_email"]) or send_email:
            to_email = getattr(user, self.options["email_column"])
            current_app.features.emails.send(to_email, "users/reset_password.txt", user=user, token=token)
        return token