Add permissions to menus

This commit is contained in:
William Bouzourène 2025-01-17 16:21:16 +01:00
parent 6152cff54a
commit 6b27dd545a
4 changed files with 52 additions and 16 deletions

View file

@ -10,14 +10,16 @@ import (
)
type TemplatesGlobals struct {
LoggedIn bool
TotpVerified bool
UserID uint
UserEmail string
UserFullname string
UserIsAdmin bool
TimeStart time.Time
ColorMode string
LoggedIn bool
TotpVerified bool
UserID uint
UserEmail string
UserFullname string
UserIsAdmin bool
TimeStart time.Time
ColorMode string
AllowMembersPage bool
AllowContactsPage bool
}
func TemplatesMiddleware(c *fiber.Ctx) error {
@ -59,6 +61,28 @@ func TemplatesMiddleware(c *fiber.Ctx) error {
globals.UserFullname = user.Name
globals.UserIsAdmin = user.IsAdmin
}
showMember, _ := helpers.PermissionsGetSections(
userid.(uint), "show_member",
)
showArchivedMember, _ := helpers.PermissionsGetSections(
userid.(uint), "show_archived_member",
)
if len(showMember) > 0 || len(showArchivedMember) > 0 {
globals.AllowMembersPage = true
}
showContact, _ := helpers.PermissionsGetSections(
userid.(uint), "show_contact",
)
showArchivedContact, _ := helpers.PermissionsGetSections(
userid.(uint), "show_archived_contact",
)
if len(showContact) > 0 || len(showArchivedContact) > 0 {
globals.AllowContactsPage = true
}
}
totpVerified := sess.Get("totp-verified")