got logging in to work
This commit is contained in:
+7
-4
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -16,8 +15,12 @@ func homeHandler(w 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)
|
||||
if check_password(pwAttempt) {
|
||||
session, _ := store.Get(req, "creds")
|
||||
session.Values["logged in"] = true
|
||||
session.Save(req, w)
|
||||
http.Redirect(w, req, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
T("login.html").Execute(w, map[string]interface{}{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user