@rpcbase/server 0.324.0 → 0.326.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ /* @flow */
2
+ const glob = require("glob")
3
+ const path = require("path")
4
+
5
+
6
+ const is_pascal_case = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str)
7
+
8
+
9
+ const load_models = () => {
10
+ const wd = process.cwd()
11
+
12
+ const models_dir = path.join(wd, "./src/models")
13
+
14
+ const files = glob.sync(path.join(models_dir, "./**/*.js"))
15
+
16
+ files
17
+ .filter((f) => !path.dirname(f).endsWith("/helpers"))
18
+ .filter((f) => is_pascal_case(path.basename(f, ".js")))
19
+ .forEach((f) => require(f))
20
+
21
+ }
22
+
23
+ load_models()
package/boot/shared.js CHANGED
@@ -6,6 +6,8 @@ require("../extend-expect")
6
6
  const mongoose = require("../mongoose")
7
7
  require("../src/access-control")(mongoose)
8
8
 
9
+ require("./load_models")
10
+
9
11
  const {database, firebase} = require("../")
10
12
 
11
13
  database()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.324.0",
3
+ "version": "0.326.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -49,12 +49,13 @@ const check_apply_permissions = (ac_config, model_name, operation, user_id, item
49
49
 
50
50
  const conditions = query.getQuery()
51
51
 
52
+ // TMP: warn if user supplied _owners, which is currently overwritten for ACL
52
53
  if (conditions._owners) {
53
- if (conditions._owners.length !== 1 || conditions._owners[0] !== user_id) {
54
- console.log(colors.yellow("Warning!"), model_name, "ACL for read is owner, but client is sending _owners in query, the field will be overwritten")
55
- console.log("received conditions._owners:", JSON.stringify(conditions._owners))
54
+ if (JSON.stringify(conditions._owners) !== `{"$in":["${user_id}"]}`) {
55
+ console.log(colors.yellow("Warning!"), model_name, "ACL for read is owner, but client is sending _owners in query, the field will be overwritten", "\nreceived conditions._owners:", JSON.stringify(conditions._owners))
56
56
  }
57
57
  }
58
+
58
59
  // TODO: implement dynamic ACL based on what the application allows the user to read
59
60
  query.setQuery({
60
61
  ...conditions,