🧹 Remove Debug Logging - Authentication Issue Fixed
✅ Ownership Indicators Now Working: - Bob's collections properly show userRole: 'owner' - Alice's public collections show userRole: null - Authentication headers fix resolved the issue 🧹 Cleanup: - Removed debug console.log statements - Cleaned up server-side logging - Restored clean, production-ready code The authentication issue is fully resolved! Bob now sees proper ownership indicators (👑 Owner badges) on his collections while Alice's public collections show as viewable without ownership indicators.
This commit is contained in:
parent
7077fc9e25
commit
f11a7fef36
3 changed files with 0 additions and 34 deletions
|
|
@ -23,7 +23,6 @@ export default async function handler(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentUserId = user.userId;
|
const currentUserId = user.userId;
|
||||||
console.log('🔍 Debug - Collections API - Current user:', user);
|
|
||||||
|
|
||||||
// Get collections based on ownership, collaboration, or public visibility
|
// Get collections based on ownership, collaboration, or public visibility
|
||||||
const result = await sql`
|
const result = await sql`
|
||||||
|
|
@ -51,14 +50,6 @@ export default async function handler(req, res) {
|
||||||
ORDER BY c.updated_at DESC
|
ORDER BY c.updated_at DESC
|
||||||
`;
|
`;
|
||||||
|
|
||||||
console.log('🔍 Debug - Collections API - Query results:', result.rows.map(r => ({
|
|
||||||
name: r.name,
|
|
||||||
user_id: r.user_id,
|
|
||||||
creator_email: r.creator_email,
|
|
||||||
user_role: r.user_role,
|
|
||||||
effective_role: r.effective_role
|
|
||||||
})));
|
|
||||||
|
|
||||||
const collections = result.rows.map(collection => ({
|
const collections = result.rows.map(collection => ({
|
||||||
id: collection.id,
|
id: collection.id,
|
||||||
slug: collection.slug,
|
slug: collection.slug,
|
||||||
|
|
@ -75,12 +66,6 @@ export default async function handler(req, res) {
|
||||||
userRole: collection.effective_role
|
userRole: collection.effective_role
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log('🔍 Debug - Collections API - Final response:', collections.map(c => ({
|
|
||||||
name: c.name,
|
|
||||||
userRole: c.userRole,
|
|
||||||
creator: c.creator
|
|
||||||
})));
|
|
||||||
|
|
||||||
res.status(200).json(collections);
|
res.status(200).json(collections);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ export default async function handler(req, res) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { identifier } = req.query;
|
const { identifier } = req.query;
|
||||||
console.log('🔍 Debug - Thumbnails API - Identifier:', identifier);
|
|
||||||
|
|
||||||
// Get authenticated user
|
// Get authenticated user
|
||||||
const user = await getUserFromRequest(req);
|
const user = await getUserFromRequest(req);
|
||||||
|
|
@ -28,15 +27,12 @@ export default async function handler(req, res) {
|
||||||
return res.status(401).json({ error: 'Authentication required' });
|
return res.status(401).json({ error: 'Authentication required' });
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('🔍 Debug - Thumbnails API - User:', user);
|
|
||||||
|
|
||||||
if (!identifier) {
|
if (!identifier) {
|
||||||
return res.status(400).json({ error: 'Collection identifier is required' });
|
return res.status(400).json({ error: 'Collection identifier is required' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if identifier is a slug or numeric ID
|
// Determine if identifier is a slug or numeric ID
|
||||||
const isSlug = isValidSlug(identifier) || isNaN(parseInt(identifier));
|
const isSlug = isValidSlug(identifier) || isNaN(parseInt(identifier));
|
||||||
console.log('🔍 Debug - Thumbnails API - Is slug:', isSlug);
|
|
||||||
|
|
||||||
// Verify user has access to this collection
|
// Verify user has access to this collection
|
||||||
let collectionResult;
|
let collectionResult;
|
||||||
|
|
|
||||||
|
|
@ -40,16 +40,6 @@ export default function Collections() {
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
// Debug logging
|
|
||||||
useEffect(() => {
|
|
||||||
console.log('🔍 Debug - Current user:', user);
|
|
||||||
console.log('🔍 Debug - Collections:', collections.map(c => ({
|
|
||||||
name: c.name,
|
|
||||||
userRole: c.userRole,
|
|
||||||
creator: c.creator
|
|
||||||
})));
|
|
||||||
}, [user, collections]);
|
|
||||||
|
|
||||||
const fetchCollections = async () => {
|
const fetchCollections = async () => {
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('auth_token');
|
const token = localStorage.getItem('auth_token');
|
||||||
|
|
@ -65,11 +55,6 @@ export default function Collections() {
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log('🔍 Debug - API response:', data.map(c => ({
|
|
||||||
name: c.name,
|
|
||||||
userRole: c.userRole,
|
|
||||||
creator: c.creator
|
|
||||||
})));
|
|
||||||
|
|
||||||
// Fetch thumbnails for each collection
|
// Fetch thumbnails for each collection
|
||||||
const collectionsWithThumbnails = await Promise.all(
|
const collectionsWithThumbnails = await Promise.all(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue