feat: Add role-based frontend controls

- Update User type to include role field
- Modify dashboard template to conditionally show admin links
- Add protected dashboard route with user context
- Update main.go to serve dashboard with proper authentication
This commit is contained in:
2026-01-26 16:56:22 -05:00
parent 734bad4697
commit f8eaca1b08
2 changed files with 4 additions and 1 deletions
+3 -1
View File
@@ -80,7 +80,9 @@ templ Dashboard(user User) {
</div>
<div class="flex items-center space-x-4">
<a href="/" class="px-3 py-2 text-sm hover:opacity-80" style="color: var(--text-secondary)">Dashboard</a>
<a href="/admin" class="px-3 py-2 text-sm hover:opacity-80" style="color: var(--text-secondary)">Admin</a>
if user.Role == "admin" {
<a href="/admin" class="px-3 py-2 text-sm hover:opacity-80" style="color: var(--text-secondary)">Admin</a>
}
<span style="color: var(--text-secondary)">Welcome, { user.Username }!</span>
<button onclick="logout()" class="btn-primary px-4 py-2 rounded text-sm">
Logout
+1
View File
@@ -4,6 +4,7 @@ type User struct {
ID string
Username string
Email string
Role string
}
type PageData struct {