|
@@ -11,7 +11,7 @@ import (
|
|
|
"html/template"
|
|
|
"github.com/gorilla/mux"
|
|
|
"github.com/gorilla/sessions"
|
|
|
-
|
|
|
+
|
|
|
|
|
|
)
|
|
|
|
|
@@ -79,7 +79,16 @@ func indexPostHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
|
|
|
func logInGetHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
- logInTemplate.Execute(w, nil)
|
|
|
+ data := struct {
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
+ Error string
|
|
|
+ }{
|
|
|
+ Username: "",
|
|
|
+ Password: "",
|
|
|
+ Error: "",
|
|
|
+ }
|
|
|
+ logInTemplate.Execute(w, data)
|
|
|
}
|
|
|
|
|
|
func logInPostHandler(w http.ResponseWriter, r *http.Request) {
|
|
@@ -97,7 +106,18 @@ func logInPostHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
fmt.Printf("%s\n%s\n",username,password)
|
|
|
http.Redirect(w, r, "/", http.StatusFound)
|
|
|
} else {
|
|
|
- logInTemplate.Execute(w, nil)
|
|
|
+ data := struct {
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
+ Error string
|
|
|
+ }{
|
|
|
+ Username: username,
|
|
|
+ Password: password,
|
|
|
+ Error: "Неверный логин либо пароль",
|
|
|
+ }
|
|
|
+ fmt.Printf("Login error")
|
|
|
+ logInTemplate.Execute(w, data)
|
|
|
+ //w.Write([]byte("Login error"))
|
|
|
}
|
|
|
}
|
|
|
|