aboutsummaryrefslogtreecommitdiff
path: root/pkg/view
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-25 22:35:47 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-25 22:35:47 +0200
commit869f50db2fbc24826762fb61d35e5f8de79296c1 (patch)
tree10bd08d7d4b34b61f74e5758e9157c2e10e069fc /pkg/view
parentc9e5d242cbba5e3b9d3ddc4465a9a1367e44cd16 (diff)
downloadlens-869f50db2fbc24826762fb61d35e5f8de79296c1.tar.gz
lens-869f50db2fbc24826762fb61d35e5f8de79296c1.tar.bz2
lens-869f50db2fbc24826762fb61d35e5f8de79296c1.zip
feat: Handle login error
Diffstat (limited to 'pkg/view')
-rw-r--r--pkg/view/auth.go10
1 files changed, 10 insertions, 0 deletions
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
}