diff --git a/application/single_app/app.py b/application/single_app/app.py
index 2354b1b5..d58eeed5 100644
--- a/application/single_app/app.py
+++ b/application/single_app/app.py
@@ -487,6 +487,16 @@ def markdown_filter(text):
# Add the filter to the Jinja environment
app.jinja_env.filters['markdown'] = markdown_filter
+# Register a custom Jinja filter for nl2br (newline to
)
+def nl2br_filter(value):
+ """Escape HTML then convert newline characters to
tags."""
+ from markupsafe import escape, Markup
+ if not value:
+ return Markup('')
+ return Markup(str(escape(value)).replace('\n', '
\n'))
+
+app.jinja_env.filters['nl2br'] = nl2br_filter
+
# =================== Default Routes =====================
@app.route('/')
@swagger_route(security=get_auth_security())
diff --git a/application/single_app/functions_settings.py b/application/single_app/functions_settings.py
index 8176939d..89367065 100644
--- a/application/single_app/functions_settings.py
+++ b/application/single_app/functions_settings.py
@@ -260,6 +260,9 @@ def get_settings(use_cosmos=False):
'max_file_size_mb': 150,
'conversation_history_limit': 10,
'default_system_prompt': '',
+ # Access denied message shown on the home page for signed-in users who lack required roles.
+ # Default is hard-coded; admins can override via Admin Settings (persisted in Cosmos DB).
+ 'access_denied_message': 'You are logged in but do not have the required permissions to access this application.\nPlease contact an administrator for access.',
'enable_file_processing_logs': True,
'file_processing_logs_timer_enabled': False,
'file_timer_value': 1,
diff --git a/application/single_app/route_frontend_admin_settings.py b/application/single_app/route_frontend_admin_settings.py
index 578e1545..2fc5abc8 100644
--- a/application/single_app/route_frontend_admin_settings.py
+++ b/application/single_app/route_frontend_admin_settings.py
@@ -869,6 +869,7 @@ def is_valid_url(url):
'max_file_size_mb': max_file_size_mb,
'conversation_history_limit': conversation_history_limit,
'default_system_prompt': form_data.get('default_system_prompt', '').strip(),
+ 'access_denied_message': form_data.get('access_denied_message', settings.get('access_denied_message', '')).strip(),
# Video file settings with Azure Video Indexer Settings
'video_indexer_endpoint': form_data.get('video_indexer_endpoint', video_indexer_endpoint).strip(),
diff --git a/application/single_app/templates/admin_settings.html b/application/single_app/templates/admin_settings.html
index 7d01f7da..f8c8b623 100644
--- a/application/single_app/templates/admin_settings.html
+++ b/application/single_app/templates/admin_settings.html
@@ -1428,6 +1428,12 @@
- You are logged in but do not have the required permissions to access this application. - Please submit a ticket to request access. + {{ app_settings.access_denied_message | nl2br }}
{% else %}