Phase 3: fix csrf issue

This commit is contained in:
2026-02-21 12:40:53 -05:00
parent 55a1ef053b
commit e024d52915
2 changed files with 5 additions and 1 deletions
+5
View File
@@ -25,6 +25,11 @@ def create_app(config_name='default'):
login_manager.login_message = 'Please log in to access this page.' login_manager.login_message = 'Please log in to access this page.'
login_manager.login_message_category = 'info' login_manager.login_message_category = 'info'
# Register csrf_token() as an app-wide Jinja2 global so templates that
# render manual forms (no WTForms object) can still inject the CSRF token.
from flask_wtf.csrf import generate_csrf
app.jinja_env.globals['csrf_token'] = generate_csrf
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True) os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
from app.routes import auth, dashboard, inspections, templates, reports, facilities from app.routes import auth, dashboard, inspections, templates, reports, facilities
-1
View File
@@ -13,7 +13,6 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form method="post" enctype="multipart/form-data" id="inspectionForm"> <form method="post" enctype="multipart/form-data" id="inspectionForm">
{{ csrf_token() | safe }}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{# Sticky toolbar #} {# Sticky toolbar #}