added setting to turn off login/edits - LOGIN_AND_EDITS
This commit is contained in:
@@ -13,6 +13,18 @@ import (
|
||||
|
||||
const csrfSessionKey = "csrf_token"
|
||||
|
||||
// RequireLoginAndEdits blocks access if LoginAndEdits setting is false.
|
||||
func (s *Server) RequireLoginAndEdits() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if !s.config.LoginAndEdits {
|
||||
c.Redirect(http.StatusFound, s.config.URLPrefix+"/?error=not_found")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) randomToken(n int) (string, error) {
|
||||
b := make([]byte, n)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user