Check if user is banned, log them out and then flash them with a funny message which is handled by error modals

This commit is contained in:
csd4ni3l
2025-08-14 13:49:33 +02:00
parent 3db4310a1d
commit 1c9bb38848
2 changed files with 48 additions and 2 deletions

View File

@@ -17,6 +17,38 @@
DANGER! Touching grass involves going outside which might cause death for certain individuals!
For more information, please visit <a href="/info" class="alert-link">the unofficial safety guide</a>!
</div>
{% block body %} {% endblock %}
{% block body %}{% endblock %}
<div class="modal fade" id="errorModal" tabindex="-1" aria-labelledby="errorModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger text-white">
<h5 class="modal-title" id="errorModalLabel">Error</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="errorModalBody">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% if category == 'error' %}
const modalBody = document.getElementById("errorModalBody");
modalBody.textContent = "{{ message|escapejs }}";
const errorModal = new bootstrap.Modal(document.getElementById('errorModal'));
errorModal.show();
{% endif %}
{% endfor %}
{% endif %}
{% endwith %}
});
</script>
</body>
</html>