feat: add magic-link admin login and speaker materials portal

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-10-07 18:27:56 +02:00
1 parent 0b6d1f2b6f
commit 68fecc2ad1
28 files changed
+1623 -232

No files matched your search

+3 -96
View File
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { AuthProvider, useAuth } from './context/AuthContext';
import { ToastProvider, useToast } from './context/ToastContext';
import { ToastProvider } from './context/ToastContext';
import { Login } from './screens/Login';
import { Dashboard } from './views/Dashboard';
import { Contacts } from './views/Contacts';
@@ -11,8 +11,7 @@ import { Activity } from './views/Activity';
import { Events } from './views/Events';
import { Interfaces } from './views/Interfaces';
import { Reports } from './views/Reports';
import { Spinner, Modal } from './components/ui';
import { DEFAULT_ADMIN_PASSWORD } from './lib/api';
import { Spinner } from './components/ui';
export type View =
| 'dashboard'
@@ -37,97 +36,6 @@ const NAV: { id: View; label: string; ico: string }[] = [
{ id: 'reports', label: 'Reports', ico: '📤' },
];
/**
* Shown once per session when an admin signs in with the default password
* (`appe-admin-2026`). Prompts them to set a personal password. Dismissable
* ("Not now"); the prompt re-appears on the next sign-in while the default is
* in use.
*/
function ChangePasswordPrompt() {
const { contact, changePassword } = useAuth();
const { push } = useToast();
const [open, setOpen] = useState(false);
const [newPassword, setNewPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
// Open the prompt when the signed-in admin is using the default password.
useEffect(() => {
if (contact && contact.password === DEFAULT_ADMIN_PASSWORD) setOpen(true);
}, [contact]);
async function onSubmit() {
if (newPassword.length < 6) {
setError('Password must be at least 6 characters.');
return;
}
if (newPassword !== confirmPassword) {
setError('Passwords do not match.');
return;
}
setBusy(true);
setError(null);
try {
await changePassword(newPassword);
push('success', 'Password updated');
setOpen(false);
setNewPassword('');
setConfirmPassword('');
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to change password');
} finally {
setBusy(false);
}
}
return (
<Modal
open={open}
onClose={() => setOpen(false)}
title="Change your password"
footer={
<>
<button className="btn ghost" onClick={() => setOpen(false)}>
Not now
</button>
<button className="btn primary" onClick={onSubmit} disabled={busy}>
{busy ? 'Saving…' : 'Save password'}
</button>
</>
}
>
<p style={{ margin: 0, fontSize: 13.5, color: 'var(--muted)' }}>
You signed in with the default admin password. Set a personal password
so only you can access this account.
</p>
<div className="field">
<label>New password</label>
<input
className="input"
type="password"
placeholder="••••••••••"
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
autoComplete="new-password"
/>
</div>
<div className="field">
<label>Confirm new password</label>
<input
className="input"
type="password"
placeholder="••••••••••"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
autoComplete="new-password"
/>
</div>
{error && <div className="login-err">{error}</div>}
</Modal>
);
}
function Shell() {
const { contact, loading, signOut } = useAuth();
const [view, setView] = useState<View>('dashboard');
@@ -144,7 +52,6 @@ function Shell() {
return (
<div className="app">
<ChangePasswordPrompt />
<aside className="sidebar">
<div className="brand">
<div className="logo"><img src="/icon-192.png" alt="APPE" /></div>