From b3afec6c0ff240c8ad93c34e713be98d25d535eb Mon Sep 17 00:00:00 2001 From: Ahmed AbdelHalim Date: Sun, 7 Sep 2025 23:07:43 +0200 Subject: Add HTTPS check on the go app with warning on login screen --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index c8d9433..fdecd70 100644 --- a/main.go +++ b/main.go @@ -214,10 +214,12 @@ func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) { } } -func (s *Server) showLoginForm(w http.ResponseWriter, _ *http.Request) { +func (s *Server) showLoginForm(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") + isHTTPS := r.TLS != nil templateData := map[string]any{ - "Error": "", + "Error": "", + "IsHTTPS": isHTTPS, } if err := s.templates.ExecuteTemplate(w, "login.html", templateData); err != nil { log.Printf("Error rendering login template: %v", err) -- cgit v1.2.3