Enforce pricelist write checks and auto-restart on DB settings change

This commit is contained in:
Mikhail Chusavitin
2026-02-05 15:44:54 +03:00
parent 08b95c293c
commit c0beed021c
5 changed files with 70 additions and 21 deletions

View File

@@ -87,6 +87,15 @@ func (h *PricelistHandler) Get(c *gin.Context) {
// Create creates a new pricelist from current prices
func (h *PricelistHandler) Create(c *gin.Context) {
canWrite, debugInfo := h.service.CanWriteDebug()
if !canWrite {
c.JSON(http.StatusForbidden, gin.H{
"error": "pricelist write is not allowed",
"debug": debugInfo,
})
return
}
// Get the database username as the creator
createdBy := h.localDB.GetDBUser()
if createdBy == "" {
@@ -104,6 +113,15 @@ func (h *PricelistHandler) Create(c *gin.Context) {
// Delete deletes a pricelist by ID
func (h *PricelistHandler) Delete(c *gin.Context) {
canWrite, debugInfo := h.service.CanWriteDebug()
if !canWrite {
c.JSON(http.StatusForbidden, gin.H{
"error": "pricelist write is not allowed",
"debug": debugInfo,
})
return
}
idStr := c.Param("id")
id, err := strconv.ParseUint(idStr, 10, 32)
if err != nil {