- Class name on raid signups now shows only as an icon tooltip instead
of trailing text (falls back to text when no icon matches).
- Discord OAuth2 linking (discord_login.php/discord_callback.php,
includes/discord.php): members connect their Discord account from
the dashboard, storing discord_id/discord_username so raid signups
can be attributed to their real Discord identity. Needs a Discord
application's client_id/client_secret in config.php.
- raids.php gets self-service signup/withdraw controls (class + group
picker, upsert semantics) for members with a linked Discord account,
plus archive/restore controls gated behind a new raids.manage
permission. New action scripts raid_signup.php, raid_unsignup.php,
raid_archive.php, raid_restore.php call the corresponding
includes/raids_api.php functions.
- Archive/restore already work today (verified live against the bot's
API - archived and restored the one active raid, signups intact).
Signup/withdraw are fully wired on the website side but need two new
bot-side endpoints (POST .../signup, DELETE .../signup/{user_id})
that don't exist yet - contract documented in the README.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
35 lines
1.3 KiB
PHP
35 lines
1.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/discord.php';
|
|
require_login();
|
|
|
|
$state = (string) ($_GET['state'] ?? '');
|
|
$code = (string) ($_GET['code'] ?? '');
|
|
$expectedState = (string) ($_SESSION['discord_oauth_state'] ?? '');
|
|
unset($_SESSION['discord_oauth_state']);
|
|
|
|
if (!empty($_GET['error'])) {
|
|
set_flash('error', 'Discord-Verknüpfung wurde abgebrochen.');
|
|
redirect('/dashboard.php');
|
|
}
|
|
|
|
if ($code === '' || $state === '' || $expectedState === '' || !hash_equals($expectedState, $state)) {
|
|
set_flash('error', 'Ungültige Antwort von Discord. Bitte erneut versuchen.');
|
|
redirect('/dashboard.php');
|
|
}
|
|
|
|
try {
|
|
$discordUser = discord_exchange_code($code);
|
|
$user = current_user();
|
|
|
|
$stmt = db()->prepare('UPDATE users SET discord_id = ?, discord_username = ? WHERE id = ?');
|
|
$stmt->execute([$discordUser['id'], $discordUser['username'], $user['id']]);
|
|
|
|
set_flash('success', 'Discord-Account "' . $discordUser['username'] . '" wurde verknüpft.');
|
|
} catch (PDOException $e) {
|
|
set_flash('error', 'Dieser Discord-Account ist bereits mit einem anderen Benutzer verknüpft.');
|
|
} catch (Throwable $e) {
|
|
set_flash('error', 'Discord-Verknüpfung fehlgeschlagen: ' . $e->getMessage());
|
|
}
|
|
|
|
redirect('/dashboard.php');
|