completionId: cgen-2fdb870a51f54b57a1bcda5063a1bd09
cgen-2fdb870a51f54b57a1bcda5063a1bd09
This commit is contained in:
parent
2e4c958fff
commit
d5b871bbe5
1 changed files with 16 additions and 35 deletions
|
|
@ -191,41 +191,22 @@ export const DiscordActivityProvider: React.FC<
|
||||||
setError(null);
|
setError(null);
|
||||||
console.log("[Discord Activity] User authenticated successfully");
|
console.log("[Discord Activity] User authenticated successfully");
|
||||||
} else {
|
} else {
|
||||||
// User already authenticated, just get their info
|
// User already authenticated
|
||||||
console.log(
|
console.log("[Discord Activity] User already authenticated");
|
||||||
"[Discord Activity] User already authenticated, fetching user data...",
|
const userData: DiscordUser = {
|
||||||
);
|
id: currentUser.id,
|
||||||
const response = await fetch("/api/discord/activity-auth", {
|
discord_id: currentUser.id,
|
||||||
method: "POST",
|
full_name: currentUser.global_name || currentUser.username,
|
||||||
headers: {
|
username: currentUser.username,
|
||||||
"Content-Type": "application/json",
|
avatar_url: currentUser.avatar
|
||||||
},
|
? `https://cdn.discordapp.com/avatars/${currentUser.id}/${currentUser.avatar}.png`
|
||||||
body: JSON.stringify({
|
: null,
|
||||||
access_token: currentUser.access_token || "",
|
bio: null,
|
||||||
}),
|
user_type: "community_member",
|
||||||
});
|
primary_arm: "labs",
|
||||||
|
};
|
||||||
if (!response.ok) {
|
setUser(userData);
|
||||||
const errorData = await response.json();
|
setError(null);
|
||||||
const errMsg = errorData.error || "Failed to fetch user data";
|
|
||||||
console.error("[Discord Activity] Fetch failed:", errMsg);
|
|
||||||
setError(errMsg);
|
|
||||||
setIsLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.success && data.user) {
|
|
||||||
console.log("[Discord Activity] User data loaded successfully");
|
|
||||||
setUser(data.user);
|
|
||||||
setError(null);
|
|
||||||
} else {
|
|
||||||
console.error(
|
|
||||||
"[Discord Activity] User data response invalid:",
|
|
||||||
data,
|
|
||||||
);
|
|
||||||
setError("Failed to load user data");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error("Discord Activity initialization error:", err);
|
console.error("Discord Activity initialization error:", err);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue