Admin password login + attendee profile self-service
- contacts.password: admin-only APPE Admin login password (event-independent); must match the bcrypt hash in auth.users.encrypted_password (set in Supabase). - APPE Admin login is now email + password (was QR token). - update_my_profile RPC (security definer, scoped to current_email()): attendees set their LinkedIn URL + show_email / show_linkedin toggles from the Profile. - Convivo Profile gains a 'Profile settings' card (LinkedIn + 2 toggles + Save). - Visibility enforced server-side in the public projection (linkedin nulled when show_linkedin off, email omitted when show_email off). - Seed: admin password appe-admin-2026; staff keep QR tokens as auth passwords. - Docs updated (schema, rpcs, seed, admin-app, screens, api-client, architecture, next-steps, README, docker-compose). 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:
1 parent
2f3952dc71
commit
0221b1a8c0
19 files changed
+290
-59
No files matched your search
@@ -48,6 +48,27 @@ export function Sheet({ open, onClose, children }: { open: boolean; onClose: ()
|
||||
);
|
||||
}
|
||||
|
||||
/** A small on/off switch with a label. */
|
||||
export function Toggle({
|
||||
checked,
|
||||
onChange,
|
||||
label,
|
||||
}: {
|
||||
checked: boolean;
|
||||
onChange: (v: boolean) => void;
|
||||
label: string;
|
||||
}) {
|
||||
return (
|
||||
<label className="toggle">
|
||||
<input type="checkbox" checked={checked} onChange={(e) => onChange(e.target.checked)} />
|
||||
<span className="track">
|
||||
<span className="knob" />
|
||||
</span>
|
||||
<span className="toggle-lbl">{label}</span>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
/** Render a string (e.g. a QR token) as a scannable QR code. */
|
||||
export function QrImage({ value, size = 180 }: { value: string; size?: number }) {
|
||||
return (
|
||||
|
||||
@@ -93,6 +93,19 @@ export async function getMyRegistration(email: string): Promise<Registration | n
|
||||
return (data as Registration) ?? null;
|
||||
}
|
||||
|
||||
/** Update the caller's own profile: LinkedIn URL + visibility toggles. */
|
||||
export async function updateMyProfile(input: {
|
||||
linkedin_url: string | null;
|
||||
show_email: boolean;
|
||||
show_linkedin: boolean;
|
||||
}): Promise<Contact> {
|
||||
return rpc<Contact>('update_my_profile', {
|
||||
p_linkedin_url: input.linkedin_url,
|
||||
p_show_email: input.show_email,
|
||||
p_show_linkedin: input.show_linkedin,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getActiveEvent(): Promise<Event | null> {
|
||||
const { data, error } = await supabase.from('events').select('*').eq('is_active', true).maybeSingle();
|
||||
if (error) throw new ApiError(error.message);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { getMyPointsLog } from '../lib/api';
|
||||
import { getMyPointsLog, updateMyProfile } from '../lib/api';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { PointsLogRow } from '../lib/types';
|
||||
import { Avatar, QrImage, Spinner } from '../components/ui';
|
||||
import { Avatar, QrImage, Spinner, Toggle } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
|
||||
checkin: 'Session check-ins',
|
||||
@@ -13,10 +14,17 @@ const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
|
||||
};
|
||||
|
||||
export function Profile() {
|
||||
const { contact, registration, signOut } = useAuth();
|
||||
const { contact, registration, signOut, refresh } = useAuth();
|
||||
const { toast } = useToast();
|
||||
const [log, setLog] = useState<PointsLogRow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// Profile self-service (LinkedIn + visibility).
|
||||
const [linkedin, setLinkedin] = useState(contact?.linkedin_url ?? '');
|
||||
const [showEmail, setShowEmail] = useState(contact?.show_email ?? false);
|
||||
const [showLinkedin, setShowLinkedin] = useState(contact?.show_linkedin ?? false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const email = contact?.email ?? '';
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,6 +50,23 @@ export function Profile() {
|
||||
const totals: Record<string, number> = {};
|
||||
for (const l of log) totals[l.category] = (totals[l.category] ?? 0) + l.delta;
|
||||
|
||||
async function saveProfile() {
|
||||
setSaving(true);
|
||||
try {
|
||||
await updateMyProfile({
|
||||
linkedin_url: linkedin.trim() || null,
|
||||
show_email: showEmail,
|
||||
show_linkedin: showLinkedin,
|
||||
});
|
||||
await refresh();
|
||||
toast('Profile updated', 'ok');
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Could not save profile', 'err');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="h1">Profile</div>
|
||||
@@ -68,6 +93,30 @@ export function Profile() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="h2" style={{ marginBottom: 6 }}>Profile settings</div>
|
||||
<div className="muted small" style={{ marginBottom: 12 }}>
|
||||
Choose what other attendees can see on your profile.
|
||||
</div>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<div className="muted small" style={{ marginBottom: 4 }}>LinkedIn</div>
|
||||
<input
|
||||
className="input"
|
||||
type="url"
|
||||
placeholder="https://linkedin.com/in/you"
|
||||
value={linkedin}
|
||||
onChange={(e) => setLinkedin(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginBottom: 14 }}>
|
||||
<Toggle checked={showEmail} onChange={setShowEmail} label="Show my email" />
|
||||
<Toggle checked={showLinkedin} onChange={setShowLinkedin} label="Show my LinkedIn" />
|
||||
</div>
|
||||
<button className="btn primary" disabled={saving} onClick={() => void saveProfile()}>
|
||||
{saving ? 'Saving…' : 'Save profile'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="h2" style={{ marginBottom: 6 }}>Points breakdown</div>
|
||||
{loading ? (
|
||||
|
||||
@@ -88,6 +88,20 @@ body {
|
||||
.input:focus { border-color: var(--accent); }
|
||||
textarea.input { resize: none; min-height: 96px; }
|
||||
.divider { height: 1px; background: var(--line); margin: 4px 0; }
|
||||
/* toggle switch */
|
||||
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
|
||||
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
|
||||
.toggle .track {
|
||||
width: 42px; height: 24px; border-radius: 999px; background: var(--line);
|
||||
position: relative; transition: background .15s; flex-shrink: 0;
|
||||
}
|
||||
.toggle .knob {
|
||||
position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
|
||||
background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
|
||||
}
|
||||
.toggle input:checked + .track { background: var(--accent); }
|
||||
.toggle input:checked + .track .knob { transform: translateX(18px); }
|
||||
.toggle-lbl { font-size: 14px; font-weight: 600; }
|
||||
|
||||
/* ---------- Tab bar ---------- */
|
||||
.tabbar {
|
||||
|
||||
Reference in new issue
Block a user