Dashboard: always show Settings link; non-admins get an explanation of their role
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2efc945192
commit
dee245ea27
2 files changed
+6
-3
No files matched your search
+5
-1
@@ -1575,7 +1575,11 @@ app.get('/dashboard', requireDashboardAuth, (_req, res) => {
|
||||
app.get('/dashboard/account', requireDashboardAuth, (_req, res) => {
|
||||
sendHtml(res, 'dashboard-account.html');
|
||||
});
|
||||
app.get('/dashboard/settings', requireDashboardAuth, requireAdmin, (_req, res) => {
|
||||
app.get('/dashboard/settings', requireDashboardAuth, (req, res) => {
|
||||
if (req.dashUser.role !== 'admin') {
|
||||
const esc = (t) => String(t).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
return res.status(403).send(`<!doctype html><meta name="viewport" content="width=device-width,initial-scale=1"><body style="font-family:system-ui;max-width:32rem;margin:3rem auto;padding:0 1rem"><h2>Settings are admin-only</h2><p>You are signed in as <b>${esc(req.dashUser.username)}</b> (role: <b>${esc(req.dashUser.role || 'none')}</b>).</p><p>Sign out and sign in with your admin account, or ask an admin to change your role on the Account page.</p><p><a href="/dashboard/account">Account</a> · <a href="/dashboard/logout">Sign out</a> · <a href="/dashboard">Dashboard</a></p>`);
|
||||
}
|
||||
sendHtml(res, 'dashboard-settings.html');
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user