Convivo login: staff QR asks for staff password (not email)

When a staff QR is detected, the confirm step now shows a password field
instead of the email field. Login uses the resolved contact's email + the
entered staff password (signInWithPassword). Attendees are unchanged (QR +
ticket email). Docs updated (screens.md, architecture.md).

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-08-23 19:18:59 +02:00
1 parent 5886de9d19
commit adcbb507e9
3 files changed
+81 -32

No files matched your search

+59 -19
View File
@@ -13,10 +13,14 @@ export function Login() {
const [qrToken, setQrToken] = useState('');
const [found, setFound] = useState<PublicContact | null>(null);
const [email, setEmail] = useState('');
const [staffPassword, setStaffPassword] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const { toast } = useToast();
// Staff log in with QR + their admin password; everyone else with QR + email.
const isStaff = found?.registration_type === 'staff';
async function handleScan(text: string) {
const token = text.trim();
if (!token) return;
@@ -33,16 +37,24 @@ export function Login() {
}
async function confirm() {
if (!email.trim() || !qrToken) return;
// Staff: QR + admin password (email comes from the resolved contact).
// Attendees: QR + the ticket email (the QR token is the auth password).
const loginEmail = isStaff ? found?.email : email.trim();
const loginPassword = isStaff ? staffPassword : qrToken;
if (!loginEmail || !loginPassword) return;
setBusy(true);
setError(null);
try {
const { data, error: err } = await supabase.auth.signInWithPassword({
email: email.trim(),
password: qrToken,
email: loginEmail,
password: loginPassword,
});
if (err) {
setError('Email and QR code do not match. Please try again.');
setError(
isStaff
? 'That password is incorrect. Please try again.'
: 'Email and QR code do not match. Please try again.'
);
toast('Login failed', 'err');
} else if (data.session) {
toast('Welcome back! 🎉', 'ok');
@@ -94,29 +106,57 @@ export function Login() {
</div>
</div>
<div className="card">
<div className="h2" style={{ marginBottom: 6 }}>Confirm it’s you</div>
<div className="muted small" style={{ marginBottom: 12 }}>
Enter the email address you used when you bought your ticket.
</div>
<input
className="input"
type="email"
placeholder="[email protected]"
value={email}
onChange={(e) => setEmail(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && confirm()}
autoComplete="off"
/>
{isStaff ? (
<>
<div className="h2" style={{ marginBottom: 6 }}>Staff sign in</div>
<div className="muted small" style={{ marginBottom: 12 }}>
Enter your staff password to log in.
</div>
<input
className="input"
type="password"
placeholder="••••••••••"
value={staffPassword}
onChange={(e) => setStaffPassword(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && confirm()}
autoComplete="off"
/>
</>
) : (
<>
<div className="h2" style={{ marginBottom: 6 }}>Confirm it’s you</div>
<div className="muted small" style={{ marginBottom: 12 }}>
Enter the email address you used when you bought your ticket.
</div>
<input
className="input"
type="email"
placeholder="[email protected]"
value={email}
onChange={(e) => setEmail(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && confirm()}
autoComplete="off"
/>
</>
)}
</div>
{error && <div className="muted small" style={{ color: 'var(--red)' }}>{error}</div>}
<button className="btn primary" disabled={busy || !email.trim()} onClick={confirm}>
<button
className="btn primary"
disabled={busy || (isStaff ? !staffPassword : !email.trim())}
onClick={confirm}
>
{busy ? 'Checking…' : 'Confirm & enter →'}
</button>
<button className="btn ghost small" style={{ alignSelf: 'flex-start' }} onClick={() => setStep('scan')}>
← Different lanyard
</button>
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
Demo: <b>ana.silva@nubank.com</b> · <b>bruno.costa@acme.com</b>
{isStaff ? (
'Staff: QR + your admin password'
) : (
<>Demo: <b>ana.silva@nubank.com</b> · <b>bruno.costa@acme.com</b></>
)}
</div>
</section>
);