yats.git

commit e5de02b0b132fe53c931ba8582e351843de15818

Author: Paolo Lulli <paolo@lulli.net>

Fix permissions error

 server/db/event.go | 1 +
 server/db/position.go | 1 +
 server/rest/rest-event.go | 3 ++-
 server/rest/rest-metric.go | 1 +
 server/rest/rest-position.go | 1 +


diff --git a/server/db/event.go b/server/db/event.go
index 0d53fa9772409a4401c3ec72e7cc9026a721b6d0..00614de340ecdb83cdb687ebb6a4a9c7c036a20b 100644
--- a/server/db/event.go
+++ b/server/db/event.go
@@ -26,6 +26,7 @@ 	timeAsBytes, _ := tstamp.UTC().MarshalText()
 	q := fmt.Sprintf("insert into event ( id_client, etime, name) values ('%s','%s','%s');", idClient, string(timeAsBytes), eventName)
 	Session.Query(q).Exec()
 }
+
 func CanReadSourceEvent(idClient string, sourceApp string) bool {
 	m := map[string]interface{}{}
 




diff --git a/server/db/position.go b/server/db/position.go
index c2047a8749f06f5118f68c7f20a7f573123f7460..792e3730110bf4b5827ebf05c3d14fa01f01a5f4 100644
--- a/server/db/position.go
+++ b/server/db/position.go
@@ -27,6 +27,7 @@ 	q := fmt.Sprintf("insert into position ( id_client, ptime, lat, lon, name) values ('%s','%s',%f,%f,'%s');", idClient, string(timeAsBytes), lat, lon, positionName)
 	fmt.Printf("q=%s", q)
 	Session.Query(q).Exec()
 }
+
 func CanReadSourcePosition(idClient string, sourceApp string) bool {
 	m := map[string]interface{}{}
 




diff --git a/server/rest/rest-event.go b/server/rest/rest-event.go
index 36f767df7aaa87bc01e55aefa78e976869720a7d..a3b6a114486158f8c81bfb27ce3f40c2cf3f068c 100644
--- a/server/rest/rest-event.go
+++ b/server/rest/rest-event.go
@@ -79,7 +79,8 @@ 		fmt.Printf("Client ID: %s\n ", clientCN)
 
 		if event.SourceApplication != "" {
 			if !db.CanReadSourceEvent(clientCN, event.SourceApplication) {
-				c.IndentedJSON(http.StatusAccepted, gin.H{"ret": "-1"})
+				c.IndentedJSON(http.StatusAccepted, gin.H{"ret": "-2"})
+				return
 			}
 			clientCN = event.SourceApplication
 		}




diff --git a/server/rest/rest-metric.go b/server/rest/rest-metric.go
index 89be4a2fd1629dd3abc4f6f0101209ff2f152b09..0c25f79131990e30bad695beb30c4c0590e035a5 100644
--- a/server/rest/rest-metric.go
+++ b/server/rest/rest-metric.go
@@ -82,6 +82,7 @@
 		if metric.SourceApplication != "" {
 			if !db.CanReadSourceMetric(clientCN, metric.SourceApplication, metric.Name) {
 				c.IndentedJSON(http.StatusAccepted, gin.H{"ret": "-2"})
+				return
 			}
 			clientCN = metric.SourceApplication
 		}




diff --git a/server/rest/rest-position.go b/server/rest/rest-position.go
index 762e083964b1a9f8a7af4a120c1da8d93f5ff017..f431f32484aec8f6900a50ab18356672068d174e 100644
--- a/server/rest/rest-position.go
+++ b/server/rest/rest-position.go
@@ -70,6 +70,7 @@
 		if position.SourceApplication != "" {
 			if !db.CanReadSourcePosition(clientCN, position.SourceApplication) {
 				c.IndentedJSON(http.StatusAccepted, gin.H{"ret": "-1"})
+				return
 			}
 			clientCN = position.SourceApplication
 		}