@@ -1408,13 +1408,22 @@ def validate_and_create_app_using_remote_template(app_name, template, templates)
14081408 """
14091409 # If user selects a template, it needs to exist.
14101410 if template in templates :
1411+ from reflex_cli .v2 .utils import hosting
1412+
1413+ authenticated_token = hosting .authenticated_token ()
1414+ if not authenticated_token or not authenticated_token [0 ]:
1415+ console .print (
1416+ f"Please use `reflex loginv2` to access the '{ template } ' template."
1417+ )
1418+ raise typer .Exit (3 )
1419+
14111420 template_url = templates [template ].code_url
14121421 else :
14131422 # Check if the template is a github repo.
14141423 if template .startswith ("https://github.com" ):
14151424 template_url = f"{ template .strip ('/' ).replace ('.git' , '' )} /archive/main.zip"
14161425 else :
1417- console .error (f"Template `{ template } ` not found." )
1426+ console .error (f"Template `{ template } ` not found or invalid ." )
14181427 raise typer .Exit (1 )
14191428
14201429 if template_url is None :
@@ -1451,7 +1460,7 @@ def generate_template_using_ai(template: str | None = None) -> str:
14511460
14521461
14531462def fetch_remote_templates (
1454- template : Optional [ str ] = None ,
1463+ template : str ,
14551464) -> tuple [str , dict [str , Template ]]:
14561465 """Fetch the available remote templates.
14571466
@@ -1460,9 +1469,6 @@ def fetch_remote_templates(
14601469
14611470 Returns:
14621471 The selected template and the available templates.
1463-
1464- Raises:
1465- Exit: If the template is not valid or if the template is not specified.
14661472 """
14671473 available_templates = {}
14681474
@@ -1474,19 +1480,7 @@ def fetch_remote_templates(
14741480 console .debug (f"Error while fetching templates: { e } " )
14751481 template = constants .Templates .DEFAULT
14761482
1477- if template == constants .Templates .DEFAULT :
1478- return template , available_templates
1479-
1480- if template in available_templates :
1481- return template , available_templates
1482-
1483- else :
1484- if template is not None :
1485- console .error (f"{ template !r} is not a valid template name." )
1486- console .print (
1487- f"Go to the templates page ({ constants .Templates .REFLEX_TEMPLATES_URL } ) and copy the command to init with a template."
1488- )
1489- raise typer .Exit (0 )
1483+ return template , available_templates
14901484
14911485
14921486def initialize_app (
@@ -1501,6 +1495,9 @@ def initialize_app(
15011495
15021496 Returns:
15031497 The name of the template.
1498+
1499+ Raises:
1500+ Exit: If the template is not valid or unspecified.
15041501 """
15051502 # Local imports to avoid circular imports.
15061503 from reflex .utils import telemetry
@@ -1528,7 +1525,10 @@ def initialize_app(
15281525 # change to the default to allow creation of default app
15291526 template = constants .Templates .DEFAULT
15301527 elif template == constants .Templates .CHOOSE_TEMPLATES :
1531- template , templates = fetch_remote_templates ()
1528+ console .print (
1529+ f"Go to the templates page ({ constants .Templates .REFLEX_TEMPLATES_URL } ) and copy the command to init with a template."
1530+ )
1531+ raise typer .Exit (0 )
15321532
15331533 # If the blank template is selected, create a blank app.
15341534 if template in (constants .Templates .DEFAULT ,):
0 commit comments