mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:11:13 -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');
|
||||
}
|
||||
|
||||
// Force refresh the session to get updated user state
|
||||
await supabase.auth.refreshSession();
|
||||
|
||||
// Update Novu subscriber back to current email
|
||||
if (notificationService.isEnabled()) {
|
||||
await notificationService.updateSubscriber({
|
||||
|
||||
@@ -52,17 +52,7 @@ Deno.serve(async (req) => {
|
||||
throw new Error('Unable to cancel email change: ' + (cancelError?.message || 'Unknown error'));
|
||||
}
|
||||
|
||||
// Verify the change was successful by getting the updated user
|
||||
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
|
||||
});
|
||||
console.log(`Successfully cancelled email change for user ${user.id}`);
|
||||
|
||||
// Log the cancellation in admin_audit_log
|
||||
const { error: auditError } = await supabaseAdmin
|
||||
@@ -87,9 +77,9 @@ Deno.serve(async (req) => {
|
||||
success: true,
|
||||
message: 'Email change cancelled successfully',
|
||||
user: {
|
||||
id: verifiedUser?.id ?? user.id,
|
||||
email: verifiedUser?.email ?? user.email,
|
||||
new_email: verifiedUser?.new_email ?? null,
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
new_email: null,
|
||||
},
|
||||
}),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user