🧹 Clean up code formatting and fix minor syntax inconsistencies in useDiscordOAuth.js
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Discord OAuth Composable
|
* Discord OAuth Composable
|
||||||
*
|
*
|
||||||
* Thin wrapper around useOAuth for Discord-specific flows
|
* Thin wrapper around useOAuth for Discord-specific flows
|
||||||
* Handles Discord user profile fetching and username access
|
* Handles Discord user profile fetching and username access
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* const discord = useDiscordOAuth();
|
* const discord = useDiscordOAuth();
|
||||||
* discord.login();
|
* discord.login();
|
||||||
@@ -41,7 +41,7 @@ export function useDiscordOAuth() {
|
|||||||
/**
|
/**
|
||||||
* Fetch Discord user profile from backend
|
* Fetch Discord user profile from backend
|
||||||
* Backend will use the stored Discord token to fetch from Discord API
|
* Backend will use the stored Discord token to fetch from Discord API
|
||||||
*
|
*
|
||||||
* @returns {Promise<Object>} Discord user profile
|
* @returns {Promise<Object>} Discord user profile
|
||||||
* @throws {Error} If fetch fails
|
* @throws {Error} If fetch fails
|
||||||
*/
|
*/
|
||||||
@@ -55,7 +55,7 @@ export function useDiscordOAuth() {
|
|||||||
// Fetch from backend which has the Discord token
|
// Fetch from backend which has the Discord token
|
||||||
const response = await fetch('/api/auth/discord/profile', {
|
const response = await fetch('/api/auth/discord/profile', {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${token}`
|
Authorization: `Bearer ${token}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ export function useDiscordOAuth() {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
discordUser.value = data.user;
|
discordUser.value = data.user;
|
||||||
|
|
||||||
console.log(`✅ Loaded Discord profile: ${data.user.username}`);
|
console.log(`✅ Loaded Discord profile: ${data.user.username}`);
|
||||||
return data.user;
|
return data.user;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -78,7 +78,7 @@ export function useDiscordOAuth() {
|
|||||||
/**
|
/**
|
||||||
* Login with Discord
|
* Login with Discord
|
||||||
* Uses identify scope only for minimal permissions
|
* Uses identify scope only for minimal permissions
|
||||||
*
|
*
|
||||||
* @param {Object} options - Optional options (return_to, etc.)
|
* @param {Object} options - Optional options (return_to, etc.)
|
||||||
*/
|
*/
|
||||||
function login(options = {}) {
|
function login(options = {}) {
|
||||||
@@ -99,7 +99,7 @@ export function useDiscordOAuth() {
|
|||||||
/**
|
/**
|
||||||
* Check if user is allowed to access developer tools
|
* Check if user is allowed to access developer tools
|
||||||
* Compares Discord username against backend-managed allowlist
|
* Compares Discord username against backend-managed allowlist
|
||||||
*
|
*
|
||||||
* @param {Object} userPermissions - User permissions object from backend
|
* @param {Object} userPermissions - User permissions object from backend
|
||||||
* @returns {boolean} True if user has developer access
|
* @returns {boolean} True if user has developer access
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user