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