def validate_and_create_app_using_remote_template(
    app_name: str, template: str, templates: dict[str, Template]
):
    """Validate and create an app using a remote template.

    Args:
        app_name: The name of the app.
        template: The name of the template.
        templates: The available templates.

    Raises:
        Exit: If the template is not found.
    """
    # If user selects a template, it needs to exist.
    if template in templates:
        from reflex_cli.v2.utils import hosting

        authenticated_token = hosting.authenticated_token()
        if not authenticated_token or not authenticated_token[0]:
            console.print(
                f"Please use `reflex login` to access the '{template}' template."
            )
            raise click.exceptions.Exit(3)

        template_url = templates[template].code_url
    else:
        template_parsed_url = urlparse(template)
        # Check if the template is a github repo.
        if template_parsed_url.hostname == "github.com":
            path = template_parsed_url.path.strip("/").removesuffix(".git")
            template_url = f"https://github.com/{path}/archive/main.zip"
        else:
            console.error(f"Template `{template}` not found or invalid.")
            raise click.exceptions.Exit(1)

    if template_url is None:
        return

    create_config_init_app_from_remote_template(
        app_name=app_name, template_url=template_url
    )
Validate and create an app using a remote template.

    Args:
        app_name: The name of the app.
        template: The name of the template.
        templates: The available templates.

    Raises:
        Exit: If the template is not found.
    
reflex/utils/prerequisites.py