@@ -236,6 +236,12 @@ public Response getFENCEProfile(String callback_url, Map<String, String> authReq
236
236
project_access_set .add (newRoleName );
237
237
}
238
238
239
+ // Project access set is now a set of role names that should be assigned to the user
240
+ logger .info ("getFENCEProfile() project access set: {}" , project_access_set );
241
+
242
+ // current user roles
243
+ logger .info ("getFENCEProfile() current user roles: {}" , current_user .getRoles ());
244
+
239
245
// Step 1: Remove roles that are not in the project_access_set
240
246
Set <Role > rolesToRemove = new HashSet <>();
241
247
// Also, track the roles that are assigned to the user and in the project_access_set
@@ -271,11 +277,13 @@ public Response getFENCEProfile(String callback_url, Map<String, String> authReq
271
277
// Given our reduced list of roles that should be assigned, we can determine which of those roles are not in the database
272
278
// This also tells use which roles are in the database
273
279
Set <String > rolesThatExist = roleRepo .getRoleNamesByNames (project_access_set );
274
-
275
280
if (!rolesThatExist .isEmpty ()) {
276
281
// Assign the roles that exist in the database to the user
277
282
logger .info ("getFENCEProfile() assigning roles that exist in the database: {}" , rolesThatExist );
278
- roleRepo .getRolesByNames (rolesThatExist ).forEach (role -> current_user .getRoles ().add (role ));
283
+ for (Role role : roleRepo .getRolesByNames (rolesThatExist )) {
284
+ current_user .getRoles ().add (role );
285
+ }
286
+
279
287
} else {
280
288
logger .info ("getFENCEProfile() none of the following roles exist in the database: {}" , project_access_set );
281
289
}
@@ -313,7 +321,7 @@ public Response getFENCEProfile(String callback_url, Map<String, String> authReq
313
321
}
314
322
315
323
try {
316
- userRepo .changeRole (current_user , current_user .getRoles ());
324
+ current_user = userRepo .changeRole (current_user , current_user .getRoles ());
317
325
logger .debug ("upsertRole() updated user, who now has {} roles." , current_user .getRoles ().size ());
318
326
} catch (Exception ex ) {
319
327
logger .error ("upsertRole() Could not add roles to user, because {}" , ex .getMessage ());
0 commit comments