Browse Source

Add better logs to /status route

Don't needlessly leak button's login/password in these logs
master
Lomanic 11 months ago
parent
commit
4320babfa6
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      main.go

+ 6
- 3
main.go View File

@@ -198,15 +198,18 @@ func imgHandler(w http.ResponseWriter, r *http.Request) {
198 198
 
199 199
 func statusHandler(w http.ResponseWriter, r *http.Request) {
200 200
 	user, pass, ok := r.BasicAuth()
201
-	fmt.Println("user", user, "pass", pass, "ok", ok)
201
+	fmt.Printf("status notification by button... ")
202 202
 	if !ok || user != config.ESPUSERNAME || pass != config.ESPPASSWORD {
203
+		fmt.Printf("bad authentication: user:%v pass:%v\n", user, pass)
203 204
 		w.Header().Set("WWW-Authenticate", `Basic realm="Authentication required"`)
204 205
 		http.Error(w, "Authentication required", 401)
205 206
 		return
206 207
 	}
207 208
 	q := r.URL.Query()
208
-	status.FuzIsOpen = q.Get("fuzisopen") == "1"
209
-	status.LastSeenAsOpen = q.Get("fuzisopen") == "1"
209
+	fuzIsOpen := q.Get("fuzisopen") == "1"
210
+	fmt.Printf("button pushed: %v\n", fuzIsOpen)
211
+	status.FuzIsOpen = fuzIsOpen
212
+	status.LastSeenAsOpen = fuzIsOpen
210 213
 	status.LastSeen = time.Now()
211 214
 	fmt.Fprintf(w, "OK")
212 215
 

Loading…
Cancel
Save