From 869f50db2fbc24826762fb61d35e5f8de79296c1 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Fri, 25 Aug 2023 22:35:47 +0200 Subject: feat: Handle login error --- pkg/view/auth.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/view') diff --git a/pkg/view/auth.go b/pkg/view/auth.go index 1b87235..8d87035 100644 --- a/pkg/view/auth.go +++ b/pkg/view/auth.go @@ -2,6 +2,7 @@ package view import ( "encoding/base64" + "errors" "net/http" "git.sr.ht/~gabrielgio/img/pkg/ext" @@ -45,6 +46,15 @@ func (v *AuthView) Login(w http.ResponseWriter, r *http.Request) error { ) auth, err := v.userController.Login(r.Context(), username, password) + + if errors.Is(err, service.InvalidLogin) { + templates.WritePageTemplate(w, &templates.LoginPage{ + Username: r.FormValue("username"), + Err: err.Error(), + }) + return nil + } + if err != nil { return err } -- cgit v1.2.3