From ae10e121875982d6956d6bff453544cc59a75616 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Tue, 12 Sep 2023 18:37:30 +0200 Subject: feat: Add admin control Now only admins can access settings. --- pkg/view/album.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pkg/view/album.go') diff --git a/pkg/view/album.go b/pkg/view/album.go index b19e381..e0ee405 100644 --- a/pkg/view/album.go +++ b/pkg/view/album.go @@ -30,10 +30,10 @@ func NewAlbumView( func (self *AlbumView) Index(w http.ResponseWriter, r *http.Request) error { p := getPagination(r) - token := ext.GetTokenFromCtx(r) + user := ext.GetUserFromCtx(r) // TODO: optmize call, GetPathFromUserID may no be necessary - userPath, err := self.userRepository.GetPathFromUserID(r.Context(), token.UserID) + userPath, err := self.userRepository.GetPathFromUserID(r.Context(), user.ID) if err != nil { return err } @@ -91,12 +91,12 @@ func (self *AlbumView) Index(w http.ResponseWriter, r *http.Request) error { Settings: settings, } - templates.WritePageTemplate(w, page) + templates.WritePageTemplate(w, page, user.IsAdmin) return nil } func (self *AlbumView) SetMyselfIn(r *ext.Router) { - r.GET("/album/", self.Index) - r.POST("/album/", self.Index) + r.GET("/album", self.Index) + r.POST("/album", self.Index) } -- cgit v1.2.3