mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:11:11 -05:00
Fix: Prevent logout on email change cancellation
This commit is contained in:
@@ -34,7 +34,7 @@ const profileSchema = z.object({
|
||||
type ProfileFormData = z.infer<typeof profileSchema>;
|
||||
|
||||
export function AccountProfileTab() {
|
||||
const { user, profile, refreshProfile, pendingEmail } = useAuth();
|
||||
const { user, profile, refreshProfile, pendingEmail, clearPendingEmail } = useAuth();
|
||||
const { toast } = useToast();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [avatarLoading, setAvatarLoading] = useState(false);
|
||||
@@ -173,11 +173,8 @@ export function AccountProfileTab() {
|
||||
throw new Error(data?.error || 'Failed to cancel email change');
|
||||
}
|
||||
|
||||
// Force refresh the session to get updated user state
|
||||
const { error: refreshError } = await supabase.auth.refreshSession();
|
||||
if (refreshError) {
|
||||
console.error('Session refresh error:', refreshError);
|
||||
}
|
||||
// Clear the pending email state immediately without refreshing session
|
||||
clearPendingEmail();
|
||||
|
||||
// Update Novu subscriber back to current email
|
||||
if (notificationService.isEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user