From a8d18d8812f91bb7f513b245a7918858876c80df Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Sun, 1 Oct 2023 23:21:28 -0600 Subject: [PATCH] wrap async calls into promises safari complains about bare async calls not being triggered by user action after a click allow admins to have multiple open sessions general webapp tweaks to background colors and button widths --- internal/auth/auth.go | 8 +++---- internal/auth/session.go | 6 +++-- internal/server/admin.html | 5 ++-- internal/server/index.html | 6 +++-- internal/server/login.html | 3 ++- internal/server/server.go | 3 ++- internal/server/static/admin.js | 18 +++++++------- internal/server/static/index.css | 38 +++++++++++++++++++++++++++++- internal/server/static/webauthn.js | 8 +++++-- 9 files changed, 72 insertions(+), 23 deletions(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 9649d67..ed1dd1c 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -55,10 +55,10 @@ func LoginHandler(w http.ResponseWriter, req *http.Request, ps httprouter.Params if err := user.Login(password); err != nil { code := http.StatusBadRequest status := http.StatusText(code) - if err, ok := err.(*errors.InvalidCredentials); ok { - code = err.Code() - status = err.Error() - err.Log() + if invalidCreds, ok := err.(*errors.InvalidCredentials); ok { + code = invalidCreds.Code() + status = invalidCreds.Error() + invalidCreds.Log() } else { logrus.Errorf("could not login %s: %s", username, err.Error()) } diff --git a/internal/auth/session.go b/internal/auth/session.go index ad74243..297051e 100644 --- a/internal/auth/session.go +++ b/internal/auth/session.go @@ -71,8 +71,10 @@ func NewSession(user *user.User, table db.Collection) (*Session, error) { Expires: user.TTL.FromNow(), } - // delete previous sessions - table.Find(db.Cond{"user": user.ID}).Delete() + if !user.IsAdmin { + // delete previous sessions + table.Find(db.Cond{"user": user.ID}).Delete() + } // insert new one _, err := table.Insert(sess) return sess, err diff --git a/internal/server/admin.html b/internal/server/admin.html index 6892a36..fd46e9d 100644 --- a/internal/server/admin.html +++ b/internal/server/admin.html @@ -4,7 +4,7 @@ - + puerta@nidi.to @@ -16,6 +16,7 @@ +