Skip to content

Instantly share code, notes, and snippets.

@lchanmann
Last active October 6, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lchanmann/eb103b217c5d9e49d82893bc0b13ce77 to your computer and use it in GitHub Desktop.
Save lchanmann/eb103b217c5d9e49d82893bc0b13ce77 to your computer and use it in GitHub Desktop.
diff --git a/src/foam/nanos/ruler/Rule.js b/src/foam/nanos/ruler/Rule.js
index cb01c8599..acb7bbe93 100644
--- a/src/foam/nanos/ruler/Rule.js
+++ b/src/foam/nanos/ruler/Rule.js
@@ -480,7 +480,16 @@
Subclasses of Rule should override "getUser" method to return the
appropriate user for which the permission is checked.
`,
- javaCode: 'return null;'
+ javaCode: `
+ var userExpr = getUserExpr();
+ if ( userExpr != null ) {
+ var result = userExpr.f(obj);
+ if ( result instanceof User ) {
+ return result;
+ }
+ }
+ return null;
+ `
}
],
diff --git a/nanopay/src/net/nanopay/crunch/compliance/rules.jrl b/nanopay/src/net/nanopay/crunch/compliance/rules.jrl
index 873a0cbe33..327c789c04 100644
--- a/nanopay/src/net/nanopay/crunch/compliance/rules.jrl
+++ b/nanopay/src/net/nanopay/crunch/compliance/rules.jrl
@@ -23,6 +23,14 @@ p({
}
]
},
+ "userExpr": {
+ "class":"foam.mlang.expr.Ref",
+ "arg1":{
+ class: "__Property__",
+ forClass_: "foam.nanos.crunch.UserCapabilityJunction",
+ name: "sourceId"
+ }
+ },
"asyncAction":{
"class":"net.nanopay.crunch.compliance.SecurefactSIDniValidator",
"classification":"Validate Signing Officer UserCapabilityJunction Using SecureFact"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment