diff --git a/internal/dis/component/auth/panel/templates/user.html b/internal/dis/component/auth/panel/templates/user.html index 5e72c25..510bf63 100644 --- a/internal/dis/component/auth/panel/templates/user.html +++ b/internal/dis/component/auth/panel/templates/user.html @@ -31,6 +31,7 @@ {{ end }} +{{ $showAdminURLs := .ShowAdminURLs }}

Your WissKIs

@@ -53,6 +54,11 @@ Admin + {{ if $showAdminURLs }} + + Distillery Admin Link + + {{ end }} @@ -69,6 +75,13 @@ {{ $grant.DrupalAdminRole }} + {{ if $showAdminURLs }} + + + {{ $grant.AdminURL }} + + + {{ end }} {{ end }} diff --git a/internal/dis/component/auth/panel/user.go b/internal/dis/component/auth/panel/user.go index 4df5960..c2fe8f0 100644 --- a/internal/dis/component/auth/panel/user.go +++ b/internal/dis/component/auth/panel/user.go @@ -9,6 +9,7 @@ import ( "github.com/FAU-CDI/wisski-distillery/internal/dis/component" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth" + "github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth/scopes" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating" "github.com/FAU-CDI/wisski-distillery/internal/models" @@ -26,7 +27,8 @@ type userContext struct { templating.RuntimeFlags *auth.AuthUser - Grants []GrantWithURL + ShowAdminURLs bool + Grants []GrantWithURL } type GrantWithURL struct { @@ -34,6 +36,10 @@ type GrantWithURL struct { URL template.URL } +func (g GrantWithURL) AdminURL() template.URL { + return template.URL("/admin/instance/" + g.Slug) +} + func (panel *UserPanel) routeUser(ctx context.Context) http.Handler { tpl := userTemplate.Prepare( @@ -55,6 +61,8 @@ func (panel *UserPanel) routeUser(ctx context.Context) http.Handler { return uc, nil, err } + uc.ShowAdminURLs = panel.Dependencies.Auth.CheckScope("", scopes.ScopeAdminLoggedIn, r) == nil + // replace the totp action in the menu var totpAction component.MenuItem if uc.AuthUser.IsTOTPEnabled() {