mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:11:12 -05:00
Fix: Resolve edge function auth error
This commit is contained in:
@@ -437,6 +437,7 @@ const approvalRateLimiter = rateLimiters.perUser(10);
|
||||
|
||||
serve(withRateLimit(async (req) => {
|
||||
const tracking = startRequest(); // Start request tracking
|
||||
let authenticatedUserId: string | undefined = undefined; // Declare outside try block for catch access
|
||||
|
||||
if (req.method === 'OPTIONS') {
|
||||
return new Response(null, { headers: corsHeaders });
|
||||
@@ -564,7 +565,7 @@ serve(withRateLimit(async (req) => {
|
||||
// (parks, rides, companies, ride_models) which have RLS policies
|
||||
// Security measures: User auth verified above, moderator role checked via RPC
|
||||
|
||||
const authenticatedUserId = user.id;
|
||||
authenticatedUserId = user.id;
|
||||
|
||||
// Create service role client for privileged operations (including role check)
|
||||
const supabase = createClient(
|
||||
@@ -1232,7 +1233,7 @@ serve(withRateLimit(async (req) => {
|
||||
edgeLogger.error('Approval process failed', {
|
||||
action: 'approval_process_error',
|
||||
error: errorMessage,
|
||||
userId: authenticatedUserId,
|
||||
userId: authenticatedUserId || 'unknown',
|
||||
requestId: tracking.requestId,
|
||||
duration
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user