diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-04 17:24:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-04 17:24:36 +0900 |
| commit | d87507918f33b289ac4fc4dece8a54fa3aa34923 (patch) | |
| tree | ac21e8263526daff40a0d5138c23a74a5b38ca0b /backend | |
| parent | 2034d5efe124ffa8a9bb56821a9dfcfea27425ff (diff) | |
| download | phperkaigi-2025-albatross-d87507918f33b289ac4fc4dece8a54fa3aa34923.tar.gz phperkaigi-2025-albatross-d87507918f33b289ac4fc4dece8a54fa3aa34923.tar.zst phperkaigi-2025-albatross-d87507918f33b289ac4fc4dece8a54fa3aa34923.zip | |
feat(backend): add /logout to /admin/dashboard
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/admin/handlers.go | 2 | ||||
| -rw-r--r-- | backend/admin/templates/dashboard.html | 3 | ||||
| -rw-r--r-- | backend/main.go | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/backend/admin/handlers.go b/backend/admin/handlers.go index 1c7995d..f81856c 100644 --- a/backend/admin/handlers.go +++ b/backend/admin/handlers.go @@ -236,5 +236,5 @@ func (h *AdminHandler) postGameEdit(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - return c.String(http.StatusNoContent, "") + return c.NoContent(http.StatusNoContent) } diff --git a/backend/admin/templates/dashboard.html b/backend/admin/templates/dashboard.html index 2d7e8ad..cdb8ba1 100644 --- a/backend/admin/templates/dashboard.html +++ b/backend/admin/templates/dashboard.html @@ -7,4 +7,7 @@ <p> <a href="/admin/games">Games</a> </p> +<form method="post" action="/logout"> + <button type="submit">Logout</button> +</form> {{ end }} diff --git a/backend/main.go b/backend/main.go index 7330109..2d38ee5 100644 --- a/backend/main.go +++ b/backend/main.go @@ -83,6 +83,13 @@ func main() { adminGroup := e.Group("/admin") adminHandler.RegisterHandlers(adminGroup) + // For local dev: + // This is never used in production because the reverse proxy sends /logout + // to the app server. + e.POST("/logout", func(c echo.Context) error { + return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173/logout") + }) + gameHubs.Run() if err := e.Start(":80"); err != http.ErrServerClosed { |
