fix: logout inserting html into page

This commit is contained in:
efim 2023-11-18 13:52:05 +00:00
parent d87c102d95
commit 495443e12a
2 changed files with 8 additions and 12 deletions

View File

@ -86,8 +86,9 @@ func authedPageMiddleware(
) http.Handler { ) http.Handler {
returnNoAccess := func(w http.ResponseWriter, r *http.Request) { returnNoAccess := func(w http.ResponseWriter, r *http.Request) {
log.Printf("auth middle > restricting access to %s", r.URL.Path) log.Printf("auth middle > restricting access to %s", r.URL.Path)
w.Header().Add("HX-Replace-Url", loginPath) w.Header().Add("HX-Redirect", "/")
renderLoginPage(w, "") // TODO i suppose i could add error?
return
} }
rerturnSuccess := func(w http.ResponseWriter, r *http.Request, session sessions.SessionData) { rerturnSuccess := func(w http.ResponseWriter, r *http.Request, session sessions.SessionData) {
ctx := context.WithValue(r.Context(), contextKey("session"), session) ctx := context.WithValue(r.Context(), contextKey("session"), session)

View File

@ -22,16 +22,11 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<!-- Place favicon.ico in the root directory --> <!-- Place favicon.ico in the root directory -->
</head> </head>
<body <body class="flex flex-col h-screen" hx-boost="true">
class="flex flex-col h-screen" <nav class="bg-yellow-200 flex-none h-14">
> {{if .Header.Title}} Room name: "{{.Header.Title}}"{{end}}
<nav class="bg-yellow-200 flex-none h-14"> <a class="bg-white border-2 rounded py-1 px-2" href="/logout">Logout</a>
{{if .Header.Title}} Room name: "{{.Header.Title}}"{{end}} </nav>
<button
class="bg-white border-2 rounded py-1 px-2"
hx-get="/logout"
>Logout</button>
</nav>
<!--[if lt IE 8]> <!--[if lt IE 8]>
<p class="browserupgrade"> <p class="browserupgrade">
You are using an <strong>outdated</strong> browser. Please You are using an <strong>outdated</strong> browser. Please