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:
@@ -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
|
||||
|
||||
@@ -4,6 +4,7 @@ type User struct {
|
||||
ID string
|
||||
Username string
|
||||
Email string
|
||||
Role string
|
||||
}
|
||||
|
||||
type PageData struct {
|
||||
|
||||
Reference in New Issue
Block a user