Skip to content

Commit 3325cdb

Browse files
committed
fix: buildIncrementalRoleLinks and if condition negate.
Signed-off-by: DivyPatel9881 <[email protected]>
1 parent 6e9a729 commit 3325cdb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

casbin/model/assertion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ void Assertion :: BuildIncrementalRoleLinks(RoleManager* rm, policy_op op, vecto
3030
if (char_count < 2)
3131
throw IllegalArgumentException("the number of \"_\" in role definition should be at least 2");
3232

33-
for(int i = 0 ; i < this->policy.size() ; i++){
34-
vector<string> rule = this->policy[i];
33+
for(int i = 0 ; i < rules.size() ; i++){
34+
vector<string> rule = rules[i];
3535

3636
if (rule.size() < char_count)
3737
throw IllegalArgumentException("grouping policy elements do not meet role definition");
@@ -43,6 +43,7 @@ void Assertion :: BuildIncrementalRoleLinks(RoleManager* rm, policy_op op, vecto
4343
switch(op) {
4444
case policy_op :: policy_add:
4545
this->rm->AddLink(rule[0], rule[1], domain);
46+
break;
4647
case policy_op :: policy_remove:
4748
this->rm->DeleteLink(rule[0], rule[1], domain);
4849
}

casbin/rbac/default_role_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ vector<string> DefaultRoleManager :: GetUsers(string name, vector<string> domain
254254
else if (domain.size() > 1)
255255
throw CasbinRBACException("error: domain should be 1 parameter");
256256

257-
if (this->HasRole(name))
257+
if (!this->HasRole(name))
258258
throw CasbinRBACException("error: name does not exist");
259259

260260
vector<string> names;

0 commit comments

Comments
 (0)