|
@@ -15,10 +15,16 @@ type Status struct {
|
|
|
LoggedIn bool
|
|
|
}
|
|
|
|
|
|
+type Password struct {
|
|
|
+ Matched bool
|
|
|
+}
|
|
|
+
|
|
|
func loginHandler(rw http.ResponseWriter, req *http.Request) {
|
|
|
if req.Method == "GET" {
|
|
|
password := req.FormValue("password")
|
|
|
log.Println("The typed password is:" + password)
|
|
|
+ var typed Password
|
|
|
+
|
|
|
if password == "admin" {
|
|
|
log.Println("Password is correct")
|
|
|
|
|
@@ -34,11 +40,14 @@ func loginHandler(rw http.ResponseWriter, req *http.Request) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- rw.Write([]byte("true"))
|
|
|
+ typed.Matched = true
|
|
|
log.Println("Logged in")
|
|
|
} else {
|
|
|
+ typed.Matched = false
|
|
|
log.Println("WRONG password!!")
|
|
|
}
|
|
|
+ send_message, _ := json.Marshal(typed)
|
|
|
+ rw.Write(send_message)
|
|
|
}
|
|
|
}
|
|
|
|