mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 10:11:12 -05:00
Fix Discord OAuth profile handling
This commit is contained in:
@@ -86,11 +86,24 @@ Deno.serve(async (req) => {
|
|||||||
displayName = discordData.global_name || discordData.username || null;
|
displayName = discordData.global_name || discordData.username || null;
|
||||||
usernameBase = discordData.username || null;
|
usernameBase = discordData.username || null;
|
||||||
|
|
||||||
// Construct Discord avatar URL
|
// Extract email (Discord provides it)
|
||||||
|
const discordEmail = discordData.email || null;
|
||||||
|
|
||||||
|
// Construct Discord avatar URL with proper format detection
|
||||||
if (discordData.avatar && discordData.id) {
|
if (discordData.avatar && discordData.id) {
|
||||||
avatarUrl = `https://cdn.discordapp.com/avatars/${discordData.id}/${discordData.avatar}.png?size=512`;
|
// Discord animated avatars have 'a_' prefix and use .gif extension
|
||||||
|
const isAnimated = discordData.avatar.startsWith('a_');
|
||||||
|
const extension = isAnimated ? 'gif' : 'png';
|
||||||
|
avatarUrl = `https://cdn.discordapp.com/avatars/${discordData.id}/${discordData.avatar}.${extension}?size=512`;
|
||||||
}
|
}
|
||||||
console.log('[OAuth Profile] Discord user:', { avatarUrl, displayName, usernameBase });
|
|
||||||
|
console.log('[OAuth Profile] Discord user:', {
|
||||||
|
avatarUrl,
|
||||||
|
displayName,
|
||||||
|
usernameBase,
|
||||||
|
email: discordEmail,
|
||||||
|
hasAnimatedAvatar: discordData.avatar?.startsWith('a_')
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('[OAuth Profile] Unsupported provider:', provider);
|
console.log('[OAuth Profile] Unsupported provider:', provider);
|
||||||
return new Response(JSON.stringify({ success: true, message: 'Provider not supported' }), {
|
return new Response(JSON.stringify({ success: true, message: 'Provider not supported' }), {
|
||||||
@@ -199,6 +212,7 @@ Deno.serve(async (req) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[OAuth Profile] Avatar upload failed:', {
|
console.error('[OAuth Profile] Avatar upload failed:', {
|
||||||
error: error.message,
|
error: error.message,
|
||||||
|
provider: provider,
|
||||||
accountId: CLOUDFLARE_ACCOUNT_ID,
|
accountId: CLOUDFLARE_ACCOUNT_ID,
|
||||||
accountHash: CLOUDFLARE_ACCOUNT_HASH,
|
accountHash: CLOUDFLARE_ACCOUNT_HASH,
|
||||||
hasToken: !!CLOUDFLARE_API_TOKEN,
|
hasToken: !!CLOUDFLARE_API_TOKEN,
|
||||||
|
|||||||
Reference in New Issue
Block a user