poprawki w autoryzacji

This commit is contained in:
Mateusz Gruszczyński
2025-07-11 11:02:43 +02:00
parent 7aa5c43c5a
commit 18c34d8093
3 changed files with 7 additions and 3 deletions

5
app.py
View File

@@ -251,6 +251,11 @@ def inject_time():
def inject_has_authorized_cookie():
return {'has_authorized_cookie': 'authorized' in request.cookies}
@app.context_processor
def inject_is_blocked():
ip = request.access_route[0]
return {'is_blocked': is_ip_blocked(ip)}
@app.before_request
def require_system_password():

View File

@@ -18,7 +18,7 @@
🛒 <span class="text-warning">Lista</span> Zakupów
</a>
{% if has_authorized_cookie %}
{% if has_authorized_cookie and not is_blocked %}
{% if current_user.is_authenticated %}
<div class="d-flex justify-content-center align-items-center text-white small flex-wrap text-center">
<span class="me-1">Zalogowany:</span>
@@ -34,7 +34,7 @@
<div class="d-flex align-items-center gap-2">
{% if request.endpoint != 'system_auth' %}
{% if request.endpoint and request.endpoint != 'system_auth' %}
{% if current_user.is_authenticated and current_user.is_admin %}
<a href="{{ url_for('admin_panel') }}" class="btn btn-outline-warning btn-sm">⚙️ Panel admina</a>
{% endif %}

View File

@@ -4,7 +4,6 @@
<div class="d-flex justify-content-between align-items-center flex-wrap mb-4">
<h2 class="mb-2">{{ code }} — {{ title }}</h2>
<a href="{{ url_for('main_page') }}" class="btn btn-outline-secondary">← Powrót na stronę główną</a>
</div>
<div class="card bg-dark text-white">