LuminaWebsite/discord_unlink.php
Maaxxs 1c9aa0761f Auto-refresh Discord username/avatar via OAuth refresh token
Previously the stored Discord identity only updated when a member
manually unlinked and relinked their account, so a changed Discord
avatar never showed up. The OAuth exchange now also captures the
refresh_token; discord_sync_avatar_if_stale() uses it to silently
pull the current username/avatar (throttled to once per hour) and is
called from profile.php, so opening "Mein Profil" keeps it current
without any re-consent flow. Adds discord_refresh_token and
discord_avatar_synced_at columns.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-19 07:26:02 +02:00

16 lines
491 B
PHP

<?php
require_once __DIR__ . '/includes/bootstrap.php';
require_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/dashboard.php');
}
verify_csrf();
$user = current_user();
db()->prepare(
'UPDATE users SET discord_id = NULL, discord_username = NULL, discord_avatar = NULL, discord_refresh_token = NULL, discord_avatar_synced_at = NULL WHERE id = ?'
)->execute([$user['id']]);
set_flash('success', 'Discord-Verknüpfung wurde entfernt.');
redirect('/dashboard.php');