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>
16 lines
491 B
PHP
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');
|