mirror of
https://github.com/rjNemo/auth
synced 2026-06-06 08:26:39 +00:00
24 lines
645 B
Go
24 lines
645 B
Go
package server
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func (s *Server) dashboardHandler() http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
if !s.loggedIn {
|
|
w.WriteHeader(http.StatusUnauthorized)
|
|
if err := s.templates.ExecuteTemplate(w, "unauthorized.html", nil); err != nil {
|
|
log.Printf("render unauthorized: %v", err)
|
|
http.Error(w, "template render failed", http.StatusInternalServerError)
|
|
}
|
|
return
|
|
}
|
|
|
|
if err := s.templates.ExecuteTemplate(w, "in.html", nil); err != nil {
|
|
log.Printf("render dashboard: %v", err)
|
|
http.Error(w, "template render failed", http.StatusInternalServerError)
|
|
}
|
|
}
|
|
}
|