summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.go6
-rw-r--r--static/css/styles.css1
-rw-r--r--templates/login.html7
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 @@
<main>
<div class="login">
<div class="login__container">
- {{if .Error}}
<div id="notifications__container" class="notifications__container">
+ {{if not .IsHTTPS}}
+ <div class="message warning">Consider upgrading to HTTPS for better security.</div>
+ {{end}}
+ {{if .Error}}
<div class="message error">{{.Error}}</div>
+ {{end}}
</div>
- {{end}}
<form class="login__form" method="POST" action="/login">
<input type="password" name="password" placeholder="Password" required>