+7
-1
appview/auth/auth.go
+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
+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
+1
-1
appview/state/router.go
+2
-1
appview/state/state.go
+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) {