refactor: refactor controllers and use standard library (#385)
This commit is contained in:
@@ -16,7 +16,7 @@ func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
user := c.DB.GetUserByName(username)
|
||||
user := c.dbc.GetUserByName(username)
|
||||
if user == nil || password != user.Password {
|
||||
sessAddFlashW(session, []string{"invalid username / password"})
|
||||
sessLogSave(session, w, r)
|
||||
@@ -28,12 +28,12 @@ func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
|
||||
// session and put the row into the request context
|
||||
session.Values["user"] = user.ID
|
||||
sessLogSave(session, w, r)
|
||||
http.Redirect(w, r, c.Path("/admin/home"), http.StatusSeeOther)
|
||||
http.Redirect(w, r, c.resolveProxyPath("/admin/home"), http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (c *Controller) ServeLogout(w http.ResponseWriter, r *http.Request) {
|
||||
session := r.Context().Value(CtxSession).(*sessions.Session)
|
||||
session.Options.MaxAge = -1
|
||||
sessLogSave(session, w, r)
|
||||
http.Redirect(w, r, c.Path("/admin/login"), http.StatusSeeOther)
|
||||
http.Redirect(w, r, c.resolveProxyPath("/admin/login"), http.StatusSeeOther)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user