Benachrichtigungen gefixt, Overrider der Discord Verifikation Funktion
This commit is contained in:
parent
4c3709b64e
commit
a6ae67c26b
|
|
@ -3,11 +3,16 @@
|
||||||
{% block title %}AstraOS — Benachrichtigungen{% endblock %}
|
{% block title %}AstraOS — Benachrichtigungen{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<script id="notifications-data" type="application/json">{{ notifications | tojson | safe }}</script>
|
||||||
|
|
||||||
<div x-data="{
|
<div x-data="{
|
||||||
showSendModal: false,
|
showSendModal: false,
|
||||||
sending: false,
|
sending: false,
|
||||||
form: { title: '', message: '', type: 'info' },
|
form: { title: '', message: '', type: 'info' },
|
||||||
notifications: {{ notifications | tojson | safe }},
|
notifications: [],
|
||||||
|
init() {
|
||||||
|
this.notifications = JSON.parse(document.getElementById('notifications-data').textContent);
|
||||||
|
},
|
||||||
async sendNotification() {
|
async sendNotification() {
|
||||||
if (!this.form.title || !this.form.message) return;
|
if (!this.form.title || !this.form.message) return;
|
||||||
this.sending = true;
|
this.sending = true;
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@
|
||||||
<div>
|
<div>
|
||||||
<button class="w-full text-left px-3 py-2 rounded-md transition flex justify-between items-center collapsible flex-shrink-0
|
<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 %}"
|
{% 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>
|
<span>Administration</span>
|
||||||
<svg class="w-4 h-4 transform transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<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>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
||||||
|
|
|
||||||
|
|
@ -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">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">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">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ü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="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">
|
<th scope="col" class="relative px-6 py-3">
|
||||||
<span class="sr-only">Aktionen</span>
|
<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>
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-500/20 text-red-300">Deaktiviert</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</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 — klicken zum Deaktivieren{% else %}Override inaktiv — 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-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">
|
<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>
|
<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>
|
||||||
|
|
|
||||||
|
|
@ -622,7 +622,7 @@ def login_required(f):
|
||||||
session.clear()
|
session.clear()
|
||||||
return redirect(url_for('account_disabled'))
|
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'))
|
return redirect(url_for('link_discord'))
|
||||||
|
|
||||||
session['permissions'] = get_user_permissions(session['user_id'])
|
session['permissions'] = get_user_permissions(session['user_id'])
|
||||||
|
|
@ -676,7 +676,7 @@ def login():
|
||||||
session['permissions'] = get_user_permissions(str(user['_id']))
|
session['permissions'] = get_user_permissions(str(user['_id']))
|
||||||
add_log("Benutzer-Login")
|
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")
|
flash("Bitte verknüpfe deinen Discord-Account, um fortzufahren.", "info")
|
||||||
return redirect(url_for('link_discord'))
|
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})
|
accounts_collection.update_one({'_id': ObjectId(user_id)}, {'$set': update_data})
|
||||||
return redirect(url_for('user_management'))
|
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')
|
@app.route('/account_disabled')
|
||||||
def account_disabled():
|
def account_disabled():
|
||||||
return render_template('account_disabled.html')
|
return render_template('account_disabled.html')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue