Remove a bunch of unused cruft

This commit is contained in:
James Mills
2022-10-05 11:11:40 +10:00
parent 06c8ce3410
commit a07f747eb1
25 changed files with 31 additions and 1542 deletions

View File

@@ -5,13 +5,11 @@ import (
"net/http"
"time"
log "github.com/sirupsen/logrus"
"github.com/vcraescu/go-paginator"
"github.com/justinas/nosurf"
"git.mills.io/prologic/spyda"
"git.mills.io/prologic/spyda/internal/session"
)
type Meta struct {
@@ -92,34 +90,5 @@ func NewContext(conf *Config, db Store, req *http.Request) *Context {
ctx.CSRFToken = nosurf.Token(req)
if sess := req.Context().Value(session.SessionKey); sess != nil {
if username, ok := sess.(*session.Session).Get("username"); ok {
ctx.Authenticated = true
ctx.Username = username
}
}
if ctx.Authenticated && ctx.Username != "" {
user, err := db.GetUser(ctx.Username)
if err != nil {
log.WithError(err).Warnf("error loading user object for %s", ctx.Username)
}
ctx.User = user
tokens, err := db.GetUserTokens(user)
if err != nil {
log.WithError(err).Warnf("error loading tokens for %s", ctx.Username)
}
ctx.Tokens = tokens
} else {
ctx.User = &User{}
}
if ctx.Username == conf.AdminUser {
ctx.IsAdmin = true
}
return ctx
}