Fix: 'delete all contacts for event' no longer deletes the logged-in admin

The bulk delete now excludes the currently-logged-in contact (me.email) so
you can't delete your own account out from under yourself.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-09-09 12:54:36 +02:00
1 parent a1fd108e4c
commit 996db14a98
1 file changed
+8 -3
+8 -3
View File
@@ -13,12 +13,14 @@ import {
} from '../lib/api';
import type { Contact, Event, Registration, RegistrationType, Sponsor, SponsorType } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { useAuth } from '../context/AuthContext';
import { Avatar, Empty, Modal, QrImage, Spinner, Toggle, TypeBadge } from '../components/ui';
const TYPES: RegistrationType[] = ['attendee', 'speaker', 'staff', 'sponsor'];
export function Registrations() {
const { push } = useToast();
const { contact: me } = useAuth();
const [events, setEvents] = useState<Event[]>([]);
const [selectedId, setSelectedId] = useState('');
const [loaded, setLoaded] = useState(false);
@@ -73,14 +75,17 @@ export function Registrations() {
async function deleteAllContactsForEvent() {
if (!event) return;
const emails = [...new Set(registrations.map((r) => r.contact_email))];
// Never delete the contact you're logged in as (it would log you out).
const emails = [...new Set(registrations.map((r) => r.contact_email))].filter(
(e) => e !== me?.email,
);
if (emails.length === 0) {
push('error', 'No registrations for this event to delete.');
push('error', 'No other contacts registered for this event to delete.');
return;
}
if (
!confirm(
`Delete ${emails.length} contact(s) registered for "${event.name}"? Their registrations for this event are removed (the contact is deleted entirely).`,
`Delete ${emails.length} contact(s) registered for "${event.name}"? Their registrations for this event are removed (the contact is deleted entirely). Your own account is kept.`,
)
)
return;