blob: 947985a04db6e16d9306adc020d5d7247ddb58f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package middleware
import (
"net/http"
"wyo.town/netzah/session"
)
func RequireAuth(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !session.Manager.Exists(r.Context(), "user") {
http.Redirect(w, r, "/login", http.StatusFound)
return
}
next.ServeHTTP(w, r)
})
}
|