Skip to content

Commit c50616f

Browse files
committed
add from msg.targetid option to api grant /revoke
1 parent 9dd12d3 commit c50616f

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

OpenFlowNodeRED/src/nodered/nodes/api.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,10 @@
833833

834834
$.getJSON('api_roles', function (data) {
835835
$('#node-input-targetid-select').empty();
836+
$('#node-input-targetid-select').append($('<option>', {
837+
value: "from msg.targetid",
838+
text: "from msg.targetid"
839+
}));
836840
$.each(data, function (i, ele) {
837841
$('#node-input-targetid-select').append($('<option>', {
838842
value: ele._id,
@@ -918,6 +922,10 @@
918922

919923
$.getJSON('api_roles', function (data) {
920924
$('#node-input-targetid-select').empty();
925+
$('#node-input-targetid-select').append($('<option>', {
926+
value: "from msg.targetid",
927+
text: "from msg.targetid"
928+
}));
921929
$.each(data, function (i, ele) {
922930
$('#node-input-targetid-select').append($('<option>', {
923931
value: ele._id,

OpenFlowNodeRED/src/nodered/nodes/api_nodes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,9 @@ export class grant_permission {
10061006
// if (NoderedUtil.IsNullEmpty(msg.jwt)) { return NoderedUtil.HandleError(this, "Missing jwt token"); }
10071007
let priority: number = 1;
10081008
if (!NoderedUtil.IsNullEmpty(msg.priority)) { priority = msg.priority; }
1009-
if (!NoderedUtil.IsNullEmpty(msg.targetid)) { this.config.targetid = msg.targetid; }
1009+
if (!NoderedUtil.IsNullEmpty(msg.targetid) && (NoderedUtil.IsNullEmpty(this.config.targetid) || this.config.targetid == "from msg.targetid")) {
1010+
this.config.targetid = msg.targetid;
1011+
}
10101012
if (!NoderedUtil.IsNullUndefinded(msg.bits)) { this.config.bits = msg.bits; }
10111013

10121014

@@ -1081,7 +1083,9 @@ export class revoke_permission {
10811083
this.node.status({});
10821084

10831085
// if (NoderedUtil.IsNullEmpty(msg.jwt)) { return NoderedUtil.HandleError(this, "Missing jwt token"); }
1084-
if (!NoderedUtil.IsNullEmpty(msg.targetid)) { this.config.targetid = msg.targetid; }
1086+
if (!NoderedUtil.IsNullEmpty(msg.targetid) && (NoderedUtil.IsNullEmpty(this.config.targetid) || this.config.targetid == "from msg.targetid")) {
1087+
this.config.targetid = msg.targetid;
1088+
}
10851089
if (!NoderedUtil.IsNullUndefinded(msg.bits)) { this.config.bits = msg.bits; }
10861090

10871091

0 commit comments

Comments
 (0)