diff --git a/middlewares/templates.go b/middlewares/templates.go index cfef2e5..6d15e15 100644 --- a/middlewares/templates.go +++ b/middlewares/templates.go @@ -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") diff --git a/views/admin.html b/views/admin.html index 2af40cf..f2d653d 100644 --- a/views/admin.html +++ b/views/admin.html @@ -17,7 +17,7 @@
- Gestion des sections + Gestion des sections
@@ -25,7 +25,7 @@
- Gestion des listes + Gestion des listes
@@ -33,7 +33,7 @@
- Gestion des champs supplémentaires + Gestion des champs supplémentaires
@@ -41,7 +41,7 @@
- Gestion des utilisateurs + Gestion des utilisateurs
@@ -49,7 +49,7 @@
- Gestion des utilisateurs + Gestion des utilisateurs
diff --git a/views/index.html b/views/index.html index f7baa25..a728de4 100644 --- a/views/index.html +++ b/views/index.html @@ -12,29 +12,35 @@
+ + {% if Globals.AllowMembersPage %}
- Gestion des membres + Gestion des membres
+ {% endif %} + + {% if Globals.AllowContactsPage %}
- Gestion des contacts + Gestion des contacts
+ {% endif %} {% if Globals.UserIsAdmin %}
- Administration de l'application + Administration de l'application
diff --git a/views/partials/header.html b/views/partials/header.html index 6a1b28a..1229c01 100644 --- a/views/partials/header.html +++ b/views/partials/header.html @@ -22,16 +22,22 @@