refactor: refactor controllers and use standard library (#385)

This commit is contained in:
Senan Kelly
2023-09-30 22:40:51 +01:00
committed by GitHub
parent adceff1267
commit e9accfb71f
25 changed files with 889 additions and 929 deletions

View File

@@ -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)
}