auth clean up and redirect fixes

This commit is contained in:
2026-01-24 12:20:11 -07:00
parent e4069e18e2
commit 52b4d18236
4 changed files with 28 additions and 37 deletions
+10
View File
@@ -24,6 +24,7 @@ import (
type (
webpageRouter struct {
log *logging.Logger
uiPath string
contentDir string
templater *templater.Templater
rawEvents *raw_events.Store
@@ -41,6 +42,7 @@ type (
func SetupRoutes(
logger *logging.Logger,
r gin.IRoutes,
uiPath string,
contentDir string,
rawEvents *raw_events.Store,
accts *accounts.Store,
@@ -50,6 +52,7 @@ func SetupRoutes(
s := &webpageRouter{
log: logger,
uiPath: uiPath,
contentDir: contentDir,
// TODO: clean up the references to the templates dir throughout as well (should only be referred to in the 'main' package
templater: new(templater.Templater).With(templater.Config{
@@ -101,6 +104,12 @@ func SetupRoutes(
// GET /
// compiles the page template or component template matching the url
func (s *webpageRouter) serveTemplate(c *gin.Context) (response.Response, error) {
// trim the url path prefix before loading the templates
c.Request.URL.Path = c.Request.URL.Path[len(s.uiPath):]
defer func() {
c.Request.URL.Path = s.uiPath + c.Request.URL.Path
}()
r := c.Request
ctx := r.Context()
@@ -222,6 +231,7 @@ func authorizeByMatchingAccountID(r *http.Request, acctIDPathPosition int) error
return nil
}
// TODO: is this error type even needed anymore?
func (e ErrTemplateNotFound) Error() string {
if e.err != nil {
return fmt.Sprintf("template not found: %v", e.err)