// PrivateStoreItemMiddleware controls access rights to item editing
PrivateStoreItemMiddleware controls access rights to item editing
// PrivateStoreItemMiddleware controls access rights to item editing
func (c *Context) PrivateStoreItemMiddleware(w web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) {
	if r.PathParams["item"] != "" && r.PathParams["item"] != "new" {
		item, _ := FindItemByUuid(r.PathParams["item"])
		if item == nil {
			http.NotFound(w, r.Request)
			return
		}
		c.CanEdit = item.Store.UserIsAdministration(c.ViewUser.Uuid) || c.ViewUser.IsAdmin || c.ViewUser.IsStaff
		if !c.CanEdit {
			http.NotFound(w, r.Request)
			return
		}
		viewItem := item.ViewItem(c.ViewUser.Language)
		c.ViewItem = &viewItem
	} else {
		item := Item{}
		viewItem := item.ViewItem(c.ViewUser.Language)
		c.ViewItem = &viewItem
	}
	next(w, r)
}
func ( c * Context ) PrivateStoreItemMiddleware ( w web . ResponseWriter , r * web . Request , next web . NextMiddlewareFunc ) { if r . PathParams [ " " ] != " " && r . PathParams [ " " ] != " " { item , _ := FindItemByUuid ( r . PathParams [ " " ] ) if item == nil { http . NotFound ( w , r . Request ) return } c . CanEdit = item . Store . UserIsAdministration ( c . ViewUser . Uuid ) || c . ViewUser . IsAdmin || c . ViewUser . IsStaff if ! c . CanEdit { http . NotFound ( w , r . Request ) return } viewItem := item . ViewItem ( c . ViewUser . Language ) c . ViewItem = & viewItem } else { item := Item { } viewItem := item . ViewItem ( c . ViewUser . Language ) c . ViewItem = & viewItem } next ( w , r ) }
PrivateStoreItemMiddleware controls access rights to item editing
PrivateStoreItemMiddleware controls access rights to item editing
// if item not found // if item does not belong to user's store