remove unused UserDropdown method from AuthController and update routes

This commit is contained in:
fabio 2026-03-06 22:16:29 +01:00
parent 82478b98e8
commit 803c83d890
2 changed files with 1 additions and 29 deletions

View File

@ -1,9 +1,7 @@
package controllers
import (
"bytes"
"errors"
"html/template"
"strings"
httpmw "trustcontact/internal/http/middleware"
@ -263,29 +261,3 @@ func (ac *AuthController) UpdateTheme(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusNoContent)
}
func (ac *AuthController) UserDropdown(c *fiber.Ctx) error {
currentUser, ok := httpmw.CurrentUserFromContext(c)
if !ok {
return c.SendStatus(fiber.StatusUnauthorized)
}
files := []string{
"web/templates/partials/user_dropdown.html",
}
tmpl, err := template.ParseFiles(files...)
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("cannot render dropdown")
}
viewData := map[string]any{
"CurrentUser": currentUser,
}
var out bytes.Buffer
if err := tmpl.ExecuteTemplate(&out, "user_dropdown", viewData); err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("cannot render dropdown")
}
c.Type("html", "utf-8")
return c.Send(out.Bytes())
}

View File

@ -30,6 +30,7 @@ func RegisterRoutes(app *fiber.App, store *session.Store, database *gorm.DB, cfg
return fmt.Errorf("init auth service: %w", err)
}
authController := controllers.NewAuthController(authService)
privateSPADir := filepath.FromSlash("quasar/private_section/dist/spa")
privateController := controllers.NewPrivateController(privateSPADir)
adminSPADir := filepath.FromSlash("quasar/admin_section/dist/spa")
@ -54,7 +55,6 @@ func RegisterRoutes(app *fiber.App, store *session.Store, database *gorm.DB, cfg
app.Get("/forbidden", authController.ShowForbidden)
app.Post("/preferences/lang", httpmw.RequireAuth(), authController.UpdateLanguage)
app.Post("/preferences/theme", httpmw.RequireAuth(), authController.UpdateTheme)
app.Get("/partials/user-dropdown", httpmw.RequireAuth(), authController.UserDropdown)
// Quasar admin SPA assets are emitted with absolute paths (/assets, /icons, /favicon.ico).
// Protect them with the same auth/admin middleware used by /admin.