AstraOS Ver. 1.44
All checks were successful
Deploy AstraOS Panel / deploy (push) Successful in 12s

Benachrichtigungen gefixt,
Overrider der Discord Verifikation Funktion
This commit is contained in:
elias 2026-08-18 18:57:50 +02:00
parent 4c3709b64e
commit a6ae67c26b
4 changed files with 46 additions and 4 deletions

View file

@ -3,11 +3,16 @@
{% block title %}AstraOS — Benachrichtigungen{% endblock %}
{% block content %}
<script id="notifications-data" type="application/json">{{ notifications | tojson | safe }}</script>
<div x-data="{
showSendModal: false,
sending: false,
form: { title: '', message: '', type: 'info' },
notifications: {{ notifications | tojson | safe }},
notifications: [],
init() {
this.notifications = JSON.parse(document.getElementById('notifications-data').textContent);
},
async sendNotification() {
if (!this.form.title || !this.form.message) return;
this.sending = true;

View file

@ -199,7 +199,7 @@
<div>
<button class="w-full text-left px-3 py-2 rounded-md transition flex justify-between items-center collapsible flex-shrink-0
{% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}"
data-open="{% if active_page in ['user_management', 'role_management', 'maintenance_management', 'logs'] %}true{% else %}false{% endif %}">
data-open="{% if active_page in ['user_management', 'role_management', 'maintenance_management', 'logs', 'notifications'] %}true{% else %}false{% endif %}">
<span>Administration</span>
<svg class="w-4 h-4 transform transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>

View file

@ -49,6 +49,7 @@
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Rolle</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Discord</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Status</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider" title="Erlaubt Login ohne Discord-Verkn&#xFC;pfung">DC Override</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Erstellt am</th>
<th scope="col" class="relative px-6 py-3">
<span class="sr-only">Aktionen</span>
@ -74,6 +75,21 @@
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-500/20 text-red-300">Deaktiviert</span>
{% endif %}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<form action="/toggle_discord_override/{{ user_table_item._id }}" method="POST" class="inline">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<button type="submit"
class="px-2 py-0.5 inline-flex text-xs leading-5 font-semibold rounded-full transition
{% if user_table_item.get('discord_override', False) %}
bg-blue-500/20 text-blue-300 hover:bg-blue-500/40
{% else %}
bg-gray-600/30 text-gray-400 hover:bg-gray-600/60
{% endif %}"
title="{% if user_table_item.get('discord_override', False) %}Override aktiv &mdash; klicken zum Deaktivieren{% else %}Override inaktiv &mdash; klicken zum Aktivieren{% endif %}">
{% if user_table_item.get('discord_override', False) %}✅ Aktiv{% else %}⚪ Inaktiv{% endif %}
</button>
</form>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">{{ user_table_item.creation_date.strftime('%d.%m.%Y') if user_table_item.creation_date else 'N/A' }}</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button @click="openEditModal('{{ user_table_item._id | string }}')" class="mr-3 {% if maintenance_active %}text-yellow-400 hover:text-yellow-300{% else %}text-indigo-400 hover:text-indigo-300{% endif %}">Bearbeiten</button>

View file

@ -622,7 +622,7 @@ def login_required(f):
session.clear()
return redirect(url_for('account_disabled'))
if not user.get('discord_id') and request.endpoint not in ['link_discord', 'login_discord', 'callback_discord', 'logout', 'static']:
if not user.get('discord_id') and not user.get('discord_override', False) and request.endpoint not in ['link_discord', 'login_discord', 'callback_discord', 'logout', 'static']:
return redirect(url_for('link_discord'))
session['permissions'] = get_user_permissions(session['user_id'])
@ -676,7 +676,7 @@ def login():
session['permissions'] = get_user_permissions(str(user['_id']))
add_log("Benutzer-Login")
if not user.get('discord_id'):
if not user.get('discord_id') and not user.get('discord_override', False):
flash("Bitte verknüpfe deinen Discord-Account, um fortzufahren.", "info")
return redirect(url_for('link_discord'))
@ -966,6 +966,27 @@ def toggle_user_status(user_id):
accounts_collection.update_one({'_id': ObjectId(user_id)}, {'$set': update_data})
return redirect(url_for('user_management'))
@app.route('/toggle_discord_override/<user_id>', methods=['POST'])
@login_required
@permission_required('manage_users')
def toggle_discord_override(user_id):
if accounts_collection is None:
flash("Datenbankverbindung nicht verfügbar.", "danger")
return redirect(url_for('user_management'))
user = accounts_collection.find_one({'_id': ObjectId(user_id)})
if not user:
flash("Benutzer nicht gefunden.", "danger")
return redirect(url_for('user_management'))
new_override = not user.get('discord_override', False)
accounts_collection.update_one(
{'_id': ObjectId(user_id)},
{'$set': {'discord_override': new_override}}
)
state = "aktiviert" if new_override else "deaktiviert"
add_log("Discord-Override geändert", f"Benutzername: {user.get('username')}, Override: {state}")
flash(f"Discord-Override für '{user.get('username')}' wurde {state}.", "success")
return redirect(url_for('user_management'))
@app.route('/account_disabled')
def account_disabled():
return render_template('account_disabled.html')