Skip to content

Commit

Permalink
check that role does not exist before setting (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
xgp authored Oct 10, 2023
1 parent 944d119 commit 1030403
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ private void addRealmAdminRoles(RealmManager manager, RealmModel realm) {
private void addRoles(ClientModel client, RoleModel parent) {
String[] names = new String[] {ROLE_PUBLISH_EVENTS};
for (String name : names) {
RoleModel role = client.addRole(name);
role.setDescription("${role_" + name + "}");
parent.addCompositeRole(role);
if (client.getRole(name) == null) {
RoleModel role = client.addRole(name);
role.setDescription("${role_" + name + "}");
parent.addCompositeRole(role);
} else {
log.infof("Role %s already exists. Skipping...", name);
}
}
}

Expand Down

0 comments on commit 1030403

Please sign in to comment.