add param abstraction to request context

This commit is contained in:
sentriz
2020-01-17 20:09:08 +00:00
parent 4af1e43389
commit 8e5d397082
13 changed files with 207 additions and 184 deletions

View File

@@ -4,12 +4,10 @@ import (
"net/http"
"github.com/gorilla/sessions"
"senan.xyz/g/gonic/server/key"
)
func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
session := r.Context().Value(key.Session).(*sessions.Session)
session := r.Context().Value(CtxSession).(*sessions.Session)
username := r.FormValue("username")
password := r.FormValue("password")
if username == "" || password == "" {
@@ -34,7 +32,7 @@ func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
}
func (c *Controller) ServeLogout(w http.ResponseWriter, r *http.Request) {
session := r.Context().Value(key.Session).(*sessions.Session)
session := r.Context().Value(CtxSession).(*sessions.Session)
session.Options.MaxAge = -1
sessLogSave(session, w, r)
http.Redirect(w, r, "/admin/login", http.StatusSeeOther)