Remove a bunch of unused cruft
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user