returns add to PageValidationMiddleware

master
serr 2025-02-02 16:55:15 +03:00
parent 7ed1999804
commit 590a9e020a
1 changed files with 4 additions and 0 deletions

View File

@ -65,11 +65,13 @@ func PageValidationMiddleware(s *models.Site) gin.HandlerFunc {
if pageNumber > len(s.Posts) || pageNumber < 1 {
c.Redirect(http.StatusFound, "/index/1?Нет доступа")
c.Abort()
return
}
case "index", "AJAXindex":
if pageNumber > s.Posts.GetMaxPageNumber() || pageNumber < 1 {
c.Redirect(http.StatusFound, "/index/1?Нет доступа")
c.Abort()
return
}
case "search", "AJAXsearch":
searchSubstring := c.Query("search")
@ -79,11 +81,13 @@ func PageValidationMiddleware(s *models.Site) gin.HandlerFunc {
c.Redirect(http.StatusFound, "/index/1?Нет доступа")
c.Abort()
return
}
default:
if pageNumber != 1 {
c.Redirect(http.StatusFound, "/index/1?Нет доступа")
c.Abort()
return
}
}