logout
This commit is contained in:
parent
dddcf38d89
commit
93000625c7
|
@ -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)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue