diff --git a/controllers/userController.go b/controllers/userController.go index de5ff66..fc07462 100644 --- a/controllers/userController.go +++ b/controllers/userController.go @@ -141,10 +141,12 @@ func (rc *UserController) LoginHandler(c *gin.Context) { } func CreateSessionData(c *gin.Context, extra any) gin.H { - _, exists := c.Get("user") + user, exists := c.Get("user") + userImpl, _ := user.(models.User) return gin.H{ "loggedIn": exists, + "isAdmin": userImpl.IsAdmin, "data": extra, } } diff --git a/views/deleteitem.html b/views/deleteitem.html index b014fc0..0cde7c9 100644 --- a/views/deleteitem.html +++ b/views/deleteitem.html @@ -5,7 +5,7 @@
Price: {{ .data.shopItem.BasePrice }}
- {{ if .loggedIn }} + {{ if .isAdmin }}Do you really want to delete this item?? diff --git a/views/header.html b/views/header.html index 0bc45ca..ce8c0ec 100644 --- a/views/header.html +++ b/views/header.html @@ -25,7 +25,7 @@ {{ end }} --> - {{ if .loggedIn }} + {{ if .isAdmin }}