The login page leads with "Mit Discord einloggen"; username/password stays available below and can be allowed or refused per user. The Discord login asks for identify + guilds.members.read, so the site itself can check that the account is on the legion's server and read its roles - no bot token on the webspace. Unknown accounts get a new user in the new status "pending", Discord-only, who sees nothing but a "Freischaltung ausstehend" page and has no permissions until approved from the user list. Permission groups can be linked to a Discord role. Linked groups are granted and revoked from the member's roles at every Discord login and then every five minutes during a session, using the stored (refreshed) user token; leaving the server removes them and ends a Discord session. Manual groups are untouched, and several linked roles simply add up their groups. New columns are added automatically on first request (includes/schema.php), since the login page itself needs them; existing accounts keep password login. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
19 lines
562 B
PHP
19 lines
562 B
PHP
<?php
|
|
require_once __DIR__ . '/../includes/bootstrap.php';
|
|
require_permission('users.edit');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
redirect('/admin/users.php');
|
|
}
|
|
verify_csrf();
|
|
|
|
$id = (int) ($_POST['id'] ?? 0);
|
|
$stmt = db()->prepare("UPDATE users SET status = 'active' WHERE id = ? AND status = 'pending'");
|
|
$stmt->execute([$id]);
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
set_flash('success', 'Benutzer wurde freigeschaltet.');
|
|
} else {
|
|
set_flash('error', 'Dieser Benutzer wartet nicht (mehr) auf eine Freischaltung.');
|
|
}
|
|
redirect('/admin/users.php');
|