Fix: Prevent logout on email change cancellation

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 16:39:52 +00:00
parent 882d06b70f
commit c00f991b1e
2 changed files with 9 additions and 6 deletions

View File

@@ -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()) {