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>
|
||||||
<div class="flex items-center space-x-4">
|
<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="/" 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>
|
<span style="color: var(--text-secondary)">Welcome, { user.Username }!</span>
|
||||||
<button onclick="logout()" class="btn-primary px-4 py-2 rounded text-sm">
|
<button onclick="logout()" class="btn-primary px-4 py-2 rounded text-sm">
|
||||||
Logout
|
Logout
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ type User struct {
|
|||||||
ID string
|
ID string
|
||||||
Username string
|
Username string
|
||||||
Email string
|
Email string
|
||||||
|
Role string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageData struct {
|
type PageData struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user