24 lines
609 B
Go
24 lines
609 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
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(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(w, map[string]interface{}{})
|
|
}
|