general improvements
This commit is contained in:
parent
bac08dc7cf
commit
ddb11f0619
25 changed files with 305 additions and 140 deletions
|
|
@ -55,7 +55,7 @@ func newContext(w http.ResponseWriter, r *http.Request, s *HTTPServer) (ctx *Con
|
|||
ctx.Token = *t
|
||||
return
|
||||
}
|
||||
ctx.Redirect(core.TotpURI, 302)
|
||||
ctx.Redirect(core.TotpURI, http.StatusFound)
|
||||
return nil
|
||||
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ func (c *Context) Exec() {
|
|||
}
|
||||
c.Data.Token = newXsrf(c.Token.RawSig()[:keySize])
|
||||
|
||||
c.Data.Version = c.Srv.Version
|
||||
c.Data.Version = c.Srv.Config.Version
|
||||
if c.Data.BodyTitle == "" {
|
||||
c.Data.BodyTitle = c.Data.Title
|
||||
}
|
||||
|
|
@ -162,6 +162,14 @@ func (c *Context) NotFound() {
|
|||
c.Exec()
|
||||
}
|
||||
|
||||
func (c *Context) Forbidden() {
|
||||
c.Template("forbiddenHandler")
|
||||
c.Data = webData{Title: "403"}
|
||||
c.Status = http.StatusForbidden
|
||||
c.Response.WriteHeader(http.StatusForbidden)
|
||||
c.Exec()
|
||||
}
|
||||
|
||||
func (c *Context) Template(name string) {
|
||||
c.T = c.Srv.templ[name]
|
||||
}
|
||||
|
|
@ -221,7 +229,7 @@ func (c *Context) LoggedOn() (ok bool) {
|
|||
}
|
||||
|
||||
func (c *Context) LogSetCookie(msg string, err error) {
|
||||
log.Println(msg, err)
|
||||
log.Printf("ctx: %s %s\n", msg, err)
|
||||
c.SetCookie(nil)
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +248,7 @@ func (c *Context) SetCookieToken(t *jwt.Token) {
|
|||
Value: c.Token.String(),
|
||||
Path: "/",
|
||||
MaxAge: int(jwt.DefaultExpiry.Seconds()),
|
||||
Secure: c.Srv.Secure,
|
||||
Secure: c.Srv.Config.SecureCookie,
|
||||
HttpOnly: true,
|
||||
SameSite: http.SameSiteStrictMode,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue