mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 16:11:12 -05:00
Fix edge function and force session refresh
This commit is contained in:
@@ -159,6 +159,9 @@ export function AccountProfileTab() {
|
|||||||
throw new Error(data?.error || 'Failed to cancel email change');
|
throw new Error(data?.error || 'Failed to cancel email change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force refresh the session to get updated user state
|
||||||
|
await supabase.auth.refreshSession();
|
||||||
|
|
||||||
// Update Novu subscriber back to current email
|
// Update Novu subscriber back to current email
|
||||||
if (notificationService.isEnabled()) {
|
if (notificationService.isEnabled()) {
|
||||||
await notificationService.updateSubscriber({
|
await notificationService.updateSubscriber({
|
||||||
|
|||||||
@@ -52,17 +52,7 @@ Deno.serve(async (req) => {
|
|||||||
throw new Error('Unable to cancel email change: ' + (cancelError?.message || 'Unknown error'));
|
throw new Error('Unable to cancel email change: ' + (cancelError?.message || 'Unknown error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the change was successful by getting the updated user
|
console.log(`Successfully cancelled email change for user ${user.id}`);
|
||||||
const { data: { user: verifiedUser }, error: verifyError } = await supabaseAdmin.auth.admin.getUserById(user.id);
|
|
||||||
|
|
||||||
if (verifyError) {
|
|
||||||
console.error('Error verifying email change cancellation:', verifyError);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Successfully cancelled email change for user ${user.id}`, {
|
|
||||||
verifiedEmail: verifiedUser?.email,
|
|
||||||
verifiedNewEmail: verifiedUser?.new_email
|
|
||||||
});
|
|
||||||
|
|
||||||
// Log the cancellation in admin_audit_log
|
// Log the cancellation in admin_audit_log
|
||||||
const { error: auditError } = await supabaseAdmin
|
const { error: auditError } = await supabaseAdmin
|
||||||
@@ -87,9 +77,9 @@ Deno.serve(async (req) => {
|
|||||||
success: true,
|
success: true,
|
||||||
message: 'Email change cancelled successfully',
|
message: 'Email change cancelled successfully',
|
||||||
user: {
|
user: {
|
||||||
id: verifiedUser?.id ?? user.id,
|
id: user.id,
|
||||||
email: verifiedUser?.email ?? user.email,
|
email: user.email,
|
||||||
new_email: verifiedUser?.new_email ?? null,
|
new_email: null,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user