Do not accept “subdirectories” for public campsite types URL
For now, it ends with the UUID or 404.
This commit is contained in:
parent
852acaccc3
commit
6e7df4ca79
|
@ -28,16 +28,21 @@ type PublicHandler struct {
|
|||
|
||||
func (h *PublicHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var head string
|
||||
head, r.URL.Path = httplib.ShiftPath(r.URL.Path)
|
||||
var typeUuid string
|
||||
typeUuid, r.URL.Path = httplib.ShiftPath(r.URL.Path)
|
||||
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
if !uuid.Valid(head) {
|
||||
if !uuid.Valid(typeUuid) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
page, err := newPublicPage(r.Context(), company, conn, user.Locale, head)
|
||||
|
||||
var head string
|
||||
head, r.URL.Path = httplib.ShiftPath(r.URL.Path)
|
||||
switch head {
|
||||
case "":
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
page, err := newPublicPage(r.Context(), company, conn, user.Locale, typeUuid)
|
||||
if database.ErrorIsNotFound(err) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
|
@ -48,6 +53,9 @@ func (h *PublicHandler) Handler(user *auth.User, company *auth.Company, conn *da
|
|||
default:
|
||||
httplib.MethodNotAllowed(w, r, http.MethodGet)
|
||||
}
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue