From 684181c34c96903acec38f1b3726a87f4ba0543b Mon Sep 17 00:00:00 2001
From: nmemmert
| Portal URL | ${escapeHtml(portalUrl)} |
| Username | ${escapeHtml(username)} |
| ${escapeHtml(username)} | |
| Password | ${escapeHtml(password)} |
When you're ready to submit an episode, fill in the episode name, the Bible passage, a short description, and attach your audio file. Everything uploads in one step.
diff --git a/server/routes/nuggets-host-upload.js b/server/routes/nuggets-host-upload.js index e6423e5..f3b7b30 100644 --- a/server/routes/nuggets-host-upload.js +++ b/server/routes/nuggets-host-upload.js @@ -159,18 +159,18 @@ export function register(app) { }) app.post('/api/nuggets-upload/login', loginRateLimiter, async (req, res) => { - const username = typeof req.body?.username === 'string' ? req.body.username.trim() : '' + const email = typeof req.body?.email === 'string' ? req.body.email.trim().toLowerCase() : '' const password = typeof req.body?.password === 'string' ? req.body.password : '' - if (!username || !password) { - res.status(400).json({ message: 'Username and password are required.' }) + if (!email || !password) { + res.status(400).json({ message: 'Email and password are required.' }) return } const data = await loadUploadHosts() - const host = data.hosts.find(h => h.username === username && h.active) + const host = data.hosts.find(h => h.email === email && h.active) if (!host || !passwordsMatch(password, host.passwordHash)) { - res.status(401).json({ message: 'Invalid username or password.' }) + res.status(401).json({ message: 'Invalid email or password.' }) return } @@ -279,12 +279,11 @@ export function register(app) { app.post('/api/admin/nuggets-upload/hosts', requireAdminAuth, async (req, res) => { const name = typeof req.body?.name === 'string' ? req.body.name.trim() : '' - const username = typeof req.body?.username === 'string' ? req.body.username.trim().toLowerCase() : '' - const password = typeof req.body?.password === 'string' ? req.body.password : '' const email = typeof req.body?.email === 'string' ? req.body.email.trim().toLowerCase() : '' + const password = typeof req.body?.password === 'string' ? req.body.password : '' - if (!name || !username || !password) { - res.status(400).json({ message: 'Name, username, and password are required.' }) + if (!name || !email || !password) { + res.status(400).json({ message: 'Name, email, and password are required.' }) return } if (password.length < 8) { @@ -293,15 +292,14 @@ export function register(app) { } const data = await loadUploadHosts() - if (data.hosts.some(h => h.username === username)) { - res.status(409).json({ message: 'Username already taken.' }) + if (data.hosts.some(h => h.email === email)) { + res.status(409).json({ message: 'An account with that email already exists.' }) return } const host = { id: randomUUID(), name, - username, email, passwordHash: hashPassword(password), active: true, @@ -310,19 +308,16 @@ export function register(app) { data.hosts.push(host) await saveUploadHosts(data) - // Send welcome email if an address was provided - if (email) { - sendNuggetsHostWelcomeEmail({ - to: email, - name, - username, - password, - portalUrl: `${process.env.SITE_URL ?? 'https://versebyversewithnate.us'}/host`, - }).catch(err => console.error('[nuggets-host] welcome email error:', err)) - } + sendNuggetsHostWelcomeEmail({ + to: email, + name, + username: email, + password, + portalUrl: `${process.env.SITE_URL ?? 'https://versebyversewithnate.us'}/host`, + }).catch(err => console.error('[nuggets-host] welcome email error:', err)) const { passwordHash: _ph, ...safeHost } = host - res.json({ ok: true, host: safeHost, emailSent: Boolean(email) }) + res.json({ ok: true, host: safeHost, emailSent: true }) }) app.put('/api/admin/nuggets-upload/hosts/:id', requireAdminAuth, async (req, res) => { diff --git a/src/AdminPage.tsx b/src/AdminPage.tsx index a8028ed..de002a8 100644 --- a/src/AdminPage.tsx +++ b/src/AdminPage.tsx @@ -1100,7 +1100,6 @@ function QrCodeImage({ url, label }: { url: string; label: string }) { interface UploadHost { id: string name: string - username: string email: string active: boolean createdAt: string @@ -1111,7 +1110,6 @@ function NuggetsUploadPortalAdmin() { const [loading, setLoading] = useState(true) const [error, setError] = useState('') const [addName, setAddName] = useState('') - const [addUsername, setAddUsername] = useState('') const [addEmail, setAddEmail] = useState('') const [addPassword, setAddPassword] = useState('') const [addError, setAddError] = useState('') @@ -1142,12 +1140,12 @@ function NuggetsUploadPortalAdmin() { const r = await fetch('/api/admin/nuggets-upload/hosts', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ name: addName, username: addUsername, email: addEmail, password: addPassword }), + body: JSON.stringify({ name: addName, email: addEmail, password: addPassword }), }) const d = await r.json() if (!r.ok) { setAddError(d.message ?? 'Failed.'); return } setAddEmailSent(Boolean(d.emailSent)) - setAddName(''); setAddUsername(''); setAddEmail(''); setAddPassword('') + setAddName(''); setAddEmail(''); setAddPassword('') reload() } finally { setAddSaving(false) @@ -1212,8 +1210,7 @@ function NuggetsUploadPortalAdmin() {Sign in with your host credentials to submit an episode.