Skip to content

Commit

Permalink
Show link to admin page for admins on account page
Browse files Browse the repository at this point in the history
  • Loading branch information
foodelevator committed Nov 4, 2024
1 parent cc79fcf commit 5742119
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion services/user/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *service) account(w http.ResponseWriter, r *http.Request) httputil.ToRes
return err
}
isAdmin, err := pls.CheckUser(r.Context(), user.KTHID, "admin-read")
return account(*user, passkeySettings)
return account(*user, passkeySettings, isAdmin)
}

func (s *service) acceptInvite(w http.ResponseWriter, r *http.Request) httputil.ToResponse {
Expand Down
13 changes: 12 additions & 1 deletion services/user/user.templ
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ templ index(passkeyLogin func() templ.Component, devLogin func() templ.Component
}
}

templ account(user export.User, passkeySettings func() templ.Component) {
templ account(user export.User, passkeySettings func() templ.Component, isAdmin bool) {
@templates.Modal() {
<div class="p-8 flex flex-col gap-4">
<div class="flex gap-2 items-center">
<p class="basis-full">{ user.FirstName } { user.FamilyName } ({ user.KTHID })</p>
if isAdmin {
<a
href="/admin"
title="Administration"
class="
bg-[#3f4c66] shrink-0 h-8 w-8 rounded-full
grid place-items-center pointer
border border-transparent outline-none focus:border-cerise-strong hover:border-cerise-light relative
"
><img class="w-3/5 h-3/5 invert" src="/public/delta.svg"/></a>
}
<a
href="/logout"
title="Log out"
Expand Down
14 changes: 12 additions & 2 deletions services/user/user_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5742119

Please sign in to comment.