user panel: Add admin interface button
This commit is contained in:
parent
8f362172db
commit
6d48261876
2 changed files with 22 additions and 1 deletions
|
|
@ -31,6 +31,7 @@
|
|||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ $showAdminURLs := .ShowAdminURLs }}
|
||||
<div class="pure-u-1">
|
||||
<h2>Your WissKIs</h2>
|
||||
<p>
|
||||
|
|
@ -53,6 +54,11 @@
|
|||
<th>
|
||||
Admin
|
||||
</th>
|
||||
{{ if $showAdminURLs }}
|
||||
<th>
|
||||
Distillery Admin Link
|
||||
</th>
|
||||
{{ end }}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -69,6 +75,13 @@
|
|||
<td>
|
||||
{{ $grant.DrupalAdminRole }}
|
||||
</td>
|
||||
{{ if $showAdminURLs }}
|
||||
<td>
|
||||
<a href="{{ $grant.AdminURL }}" class="pure-button" target="_blank" rel="noopener noreferer">
|
||||
{{ $grant.AdminURL }}
|
||||
</a>
|
||||
</td>
|
||||
{{ end }}
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue