frame template now honors current user

This commit is contained in:
2025-09-20 17:10:37 -06:00
parent a794c5919b
commit d8648ace80
8 changed files with 84 additions and 42 deletions
+10
View File
@@ -14,14 +14,17 @@ import (
"bytes"
"net/http"
"git.erbosoft.com/amy/amsterdam/database"
"github.com/CloudyKit/jet/v6"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
log "github.com/sirupsen/logrus"
)
// AmContext is the interface for Amsterdam's wapper context that exposes the required functionality.
type AmContext interface {
CurrentUser() *database.User
RC() int
OutputType() string
Render(string) error
@@ -44,6 +47,11 @@ type amContext struct {
session *sessions.Session
}
// CurrentUser returns the current user from the session.
func (c *amContext) CurrentUser() *database.User {
return c.session.Values["user"].(*database.User)
}
// RC returns the HTTP result code for the current operation.
func (c *amContext) RC() int {
return c.httprc
@@ -143,6 +151,8 @@ func NewAmContext(ctxt echo.Context) (AmContext, error) {
sess.Options = defoptions
if sess.IsNew {
SetupAmSession(sess)
} else {
log.Debugf("took the not-new-session path")
}
}
return &rc, err