This commit is contained in:
Stephen McQuay 2013-02-21 00:19:38 -08:00
parent e2d1c76142
commit bc53e1a1ff
2 changed files with 13 additions and 7 deletions

View File

@ -5,13 +5,19 @@ import (
"net/http"
)
func homeHandler(c http.ResponseWriter, req *http.Request) {
log.Printf("%v\n", req.URL)
T("index.html").Execute(c, map[string]interface{}{})
func homeHandler(w http.ResponseWriter, req *http.Request) {
session, _ := store.Get(req, "creds")
loggedIn := session.Values["logged in"]
if loggedIn == nil {
http.Redirect(w, req, "/login", http.StatusSeeOther)
}
T("index.html").Execute(w, map[string]interface{}{})
}
func loginHandler(c http.ResponseWriter, req *http.Request) {
func loginHandler(w http.ResponseWriter, req *http.Request) {
pwAttempt := req.FormValue("passwd")
// if pw matches, set session.Values["logged in"], then redirect to "/"
// else come back here..
log.Printf("%v\n", pwAttempt)
T("login.html").Execute(c, map[string]interface{}{})
T("login.html").Execute(w, map[string]interface{}{})
}