diff --git a/internal/controllers/auth_controller.go b/internal/controllers/auth_controller.go index 662c032..cce6fd9 100644 --- a/internal/controllers/auth_controller.go +++ b/internal/controllers/auth_controller.go @@ -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()) -} diff --git a/internal/http/router.go b/internal/http/router.go index 383bec8..c44ec3c 100644 --- a/internal/http/router.go +++ b/internal/http/router.go @@ -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.