mirror of
https://github.com/rjNemo/auth
synced 2026-06-06 00:16:40 +00:00
17 lines
460 B
Go
17 lines
460 B
Go
package server
|
|
|
|
import "net/http"
|
|
|
|
func (s *Server) dashboardHandler() http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
state := sessionFromContext(r.Context())
|
|
|
|
if !state.Authenticated {
|
|
w.WriteHeader(http.StatusUnauthorized)
|
|
s.render(w, "unauthorized.html", newUnauthorizedData("Sign in to continue.", state.CSRFToken))
|
|
return
|
|
}
|
|
|
|
s.render(w, "in.html", PageData{Email: state.Email, CSRFToken: state.CSRFToken})
|
|
}
|
|
}
|