diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 4e5d992..3680eb9 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -776,11 +776,14 @@ func (h *AuthHandler) UpdateUserMaxDevices(c echo.Context) error { return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid user id"}) } - err = h.db.UpdateUserMaxDevices(c.Request().Context(), database.UpdateUserMaxDevicesParams{ + user, err := h.db.UpdateUserMaxDevices(c.Request().Context(), database.UpdateUserMaxDevicesParams{ ID: pgtype.UUID{Bytes: userUUID, Valid: true}, MaxDevices: pgtype.Int4{Int32: req.MaxDevices, Valid: true}, }) if err != nil { + if err == pgx.ErrNoRows { + return c.JSON(http.StatusNotFound, map[string]string{"error": "user not found"}) + } return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) }