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/auth.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'pkg/view/auth.go') diff --git a/pkg/view/auth.go b/pkg/view/auth.go index 8d87035..318d0a3 100644 --- a/pkg/view/auth.go +++ b/pkg/view/auth.go @@ -20,8 +20,8 @@ func NewAuthView(userController *service.AuthController) *AuthView { } } -func (v *AuthView) LoginView(w http.ResponseWriter, _ *http.Request) error { - templates.WritePageTemplate(w, &templates.LoginPage{}) +func (v *AuthView) LoginView(w http.ResponseWriter, r *http.Request) error { + templates.WritePageTemplate(w, &templates.LoginPage{}, false) return nil } @@ -46,12 +46,15 @@ func (v *AuthView) Login(w http.ResponseWriter, r *http.Request) error { ) auth, err := v.userController.Login(r.Context(), username, password) + if err != nil { + return err + } if errors.Is(err, service.InvalidLogin) { templates.WritePageTemplate(w, &templates.LoginPage{ Username: r.FormValue("username"), Err: err.Error(), - }) + }, false) return nil } @@ -82,8 +85,8 @@ func Index(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) } -func (v *AuthView) InitialRegisterView(w http.ResponseWriter, _ *http.Request) error { - templates.WritePageTemplate(w, &templates.RegisterPage{}) +func (v *AuthView) InitialRegisterView(w http.ResponseWriter, r *http.Request) error { + templates.WritePageTemplate(w, &templates.RegisterPage{}, false) return nil } -- cgit v1.2.3