admin: Allow impersonation and deactivation

This commit is contained in:
Tom Wiesing 2023-01-17 12:25:23 +01:00
parent 2384ee0841
commit 7d0fb60d67
No known key found for this signature in database
6 changed files with 74 additions and 5 deletions

View file

@ -30,6 +30,7 @@ type UserPanel struct {
var (
_ component.Routeable = (*UserPanel)(nil)
_ component.Menuable = (*UserPanel)(nil)
)
func (panel *UserPanel) Routes() component.Routes {
@ -37,9 +38,18 @@ func (panel *UserPanel) Routes() component.Routes {
Prefix: "/user/",
CSRF: true,
Decorator: panel.Dependencies.Auth.Require(nil),
}
}
MenuPriority: component.MenuUser,
MenuTitle: "User",
func (panel *UserPanel) Menu(r *http.Request) []component.MenuItem {
title := "Login"
user, err := panel.Dependencies.Auth.UserOf(r)
if user != nil && err == nil {
title = user.User.User
}
return []component.MenuItem{
{Title: title, Priority: component.MenuUser, Path: "/user/"},
}
}

View file

@ -1,10 +1,11 @@
{{ template "_base.html" . }}
{{ define "title" }}User{{ end }}
{{ define "title" }}{{ .User.User }}{{ end }}
{{ define "content" }}
<div class="pure-u-1">
<p>
<ul>
<li>Username: <code>{{ .User.User }}</code></li>
{{ if .User.IsAdmin }}
<li>Role: <b>Administrator</b></li>
{{ else }}