mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 05:51:12 -05:00
Fix: Ensure authorization header is sent
This commit is contained in:
@@ -27,14 +27,23 @@ Deno.serve(async (req) => {
|
||||
// Get the user from the authorization header
|
||||
const authHeader = req.headers.get('Authorization');
|
||||
if (!authHeader) {
|
||||
throw new Error('No authorization header');
|
||||
console.error('Missing authorization header');
|
||||
throw new Error('No authorization header provided. Please ensure you are logged in.');
|
||||
}
|
||||
|
||||
const token = authHeader.replace('Bearer ', '');
|
||||
console.log('Attempting to verify user token...');
|
||||
|
||||
const { data: { user }, error: userError } = await supabaseAdmin.auth.getUser(token);
|
||||
|
||||
if (userError || !user) {
|
||||
throw new Error('Unauthorized');
|
||||
if (userError) {
|
||||
console.error('Token verification failed:', userError);
|
||||
throw new Error('Invalid or expired session. Please refresh the page and try again.');
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
console.error('No user found for token');
|
||||
throw new Error('User not found. Please refresh the page and try again.');
|
||||
}
|
||||
|
||||
console.log(`Cancelling email change for user ${user.id}`, {
|
||||
|
||||
Reference in New Issue
Block a user