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 @@ - +