mirror of
https://github.com/Such-Software/smirk-website.git
synced 2026-11-13 09:14:03 +01:00
feat: discord integration
This commit is contained in:
@@ -294,6 +294,49 @@ export async function getClaimableTips(token: string): Promise<{ tips: Claimable
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Discord OAuth2 Linking
|
||||
// =============================================================================
|
||||
|
||||
export interface DiscordAuthUrlResponse {
|
||||
auth_url: string;
|
||||
}
|
||||
|
||||
export async function getDiscordAuthUrl(token: string): Promise<DiscordAuthUrlResponse> {
|
||||
const res = await fetch(`${API_URL}/api/v1/socials/discord/auth-url`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
throw new Error(data.error || 'Failed to get Discord auth URL');
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function completeDiscordOAuth(
|
||||
token: string,
|
||||
code: string,
|
||||
state: string
|
||||
): Promise<LinkedSocial> {
|
||||
const res = await fetch(`${API_URL}/api/v1/socials/discord/callback`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify({ code, state }),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
throw new Error(data.error || 'Failed to link Discord account');
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Username Management
|
||||
// =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user