Monorepo for Tangled tangled.org
854
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix 502 on logout

my hunch is that this is caused by using a GET request, which browsers tend to cache sometimes.

authored by

oppili.bsky.social and committed by
Tangled
11fdfed0 9dc97017

+16 -4
+7 -1
appview/auth/auth.go
··· 128 128 } 129 129 130 130 func (a *Auth) ClearSession(r *http.Request, w http.ResponseWriter) error { 131 - clientSession, _ := a.Store.Get(r, appview.SessionName) 131 + clientSession, err := a.Store.Get(r, appview.SessionName) 132 + if err != nil { 133 + return fmt.Errorf("invalid session", err) 134 + } 135 + if clientSession.IsNew { 136 + return fmt.Errorf("invalid session") 137 + } 132 138 clientSession.Options.MaxAge = -1 133 139 return clientSession.Save(r, w) 134 140 }
+6 -1
appview/pages/templates/layouts/topbar.html
··· 33 33 <a href="/{{ didOrHandle .Did .Handle }}">profile</a> 34 34 <a href="/knots">knots</a> 35 35 <a href="/settings">settings</a> 36 - <a href="/logout" class="text-red-400 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300">logout</a> 36 + <a href="#" 37 + hx-post="/logout" 38 + hx-swap="none" 39 + class="text-red-400 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300"> 40 + logout 41 + </a> 37 42 </div> 38 43 </details> 39 44 {{ end }}
+1 -1
appview/state/router.go
··· 161 161 162 162 r.Get("/", s.Timeline) 163 163 164 - r.With(AuthMiddleware(s)).Get("/logout", s.Logout) 164 + r.With(AuthMiddleware(s)).Post("/logout", s.Logout) 165 165 166 166 r.Route("/login", func(r chi.Router) { 167 167 r.Get("/", s.Login)
+2 -1
appview/state/state.go
··· 165 165 166 166 func (s *State) Logout(w http.ResponseWriter, r *http.Request) { 167 167 s.auth.ClearSession(r, w) 168 - http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) 168 + w.Header().Set("HX-Redirect", "/login") 169 + w.WriteHeader(http.StatusSeeOther) 169 170 } 170 171 171 172 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) {