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 ++++-- static/css/styles.css | 1 + templates/login.html | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) 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) diff --git a/static/css/styles.css b/static/css/styles.css index 3edbaf2..961241f 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -72,6 +72,7 @@ footer { border-left-width: 14px; padding: 14px; white-space: pre-line; + margin-bottom: 1rem; } .message.loading, diff --git a/templates/login.html b/templates/login.html index bd28803..3fcd987 100644 --- a/templates/login.html +++ b/templates/login.html @@ -16,11 +16,14 @@