feat(posts): author_id nel repository + listByAuthor + helper utenti

This commit is contained in:
2026-07-05 21:49:16 +02:00
parent db92fc9c02
commit 6d1e2607ee
3 changed files with 45 additions and 6 deletions
+10
View File
@@ -68,6 +68,16 @@ export function canAccessAdminPath(role: string, pathname: string): boolean {
return true; // blog, upload, logout, showtags: tutti i loggati
}
export function getUsernameById(db: Database.Database, id: number): string | null {
const row = db.prepare('SELECT username FROM users WHERE id = ?').get(id) as { username: string } | undefined;
return row?.username ?? null;
}
export function listUsers(db: Database.Database): { id: number; username: string; role: string }[] {
return db.prepare('SELECT id, username, role FROM users ORDER BY username').all() as
{ id: number; username: string; role: string }[];
}
export function landingFor(role: string): string {
if (role === 'superuser') return '/admin/content';
return '/admin';