This commit is contained in:
Dan Ballard 2015-05-11 22:12:51 -07:00
parent dddcf38d89
commit 93000625c7
1 changed files with 11 additions and 0 deletions

View File

@ -103,6 +103,15 @@ func LoginPostHandler(w http.ResponseWriter, r *http.Request) {
}
}
// logout POST handler
func LogoutHandler(w http.ResponseWriter, r *http.Request, user *user.User) {
session, _ := store.Get(r, "c_user")
//session.Options = &sessions.Options{MaxAge: -1}
sessionWipe(session)
session.Save(r, w)
http.Redirect(w, r, "/", http.StatusFound)
}
// ?url=
func addFormHandler(w http.ResponseWriter, r *http.Request, user *user.User) {
categories.LoadCategories(db)
@ -197,6 +206,8 @@ func init_route_handlers() {
r := mux.NewRouter()
r.HandleFunc("/login", getPostHandler(LoginFormHandler, LoginPostHandler))
r.HandleFunc("/logout", userHandler(LogoutHandler))
r.HandleFunc("/add", getPostHandler(userHandler(addFormHandler), userHandler(addPostHandler)))
r.HandleFunc("/", getPostHandler(userHandler(templateFormHandler), userHandler(templatePostHandler)))