From c62441a2d1aa95561c5795171d5f94ef6a20da2d Mon Sep 17 00:00:00 2001 From: Karl Date: Sat, 19 Jul 2025 09:05:28 +0100 Subject: [PATCH] manual check on config page --- app.py | 13 +++++++++++++ templates/config_dashboard.html | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app.py b/app.py index 863685b..19c5676 100644 --- a/app.py +++ b/app.py @@ -317,6 +317,19 @@ def config_dashboard(): return redirect(url_for('config')) return render_template('config_dashboard.html') +@app.route('/check-expiring-accounts', methods=['POST']) +def check_expiring_accounts(): + """Proxies the request to check for expiring accounts to the backend.""" + if not session.get("config_logged_in"): + return jsonify({'error': 'Unauthorized'}), 401 + + backend_url = f"{app.config['BASE_URL']}/check-expiry" + try: + response = requests.post(backend_url) + return Response(response.content, status=response.status_code, mimetype=response.headers['Content-Type']) + except requests.exceptions.RequestException as e: + return jsonify({"error": str(e)}), 502 + if __name__ == "__main__": app.run( diff --git a/templates/config_dashboard.html b/templates/config_dashboard.html index 96b471a..ec23879 100644 --- a/templates/config_dashboard.html +++ b/templates/config_dashboard.html @@ -7,6 +7,7 @@

Configuration Dashboard

Welcome to the configuration page.

+ {% endblock %} @@ -27,5 +28,20 @@ document.getElementById('send-test-notification-btn').addEventListener('click', alert('An error occurred while sending the test notification.'); }); }); + +document.getElementById('check-expiring-accounts-btn').addEventListener('click', function() { + fetch('{{ url_for("check_expiring_accounts") }}', { + method: 'POST' + }).then(response => { + if (response.ok) { + alert('Expiring accounts check triggered successfully!'); + } else { + alert('Failed to trigger expiring accounts check.'); + } + }).catch(err => { + console.error('Error triggering expiring accounts check:', err); + alert('An error occurred while triggering the expiring accounts check.'); + }); +}); {% endblock %} \ No newline at end of file