Skip to content

Commit 79f14dc

Browse files
author
rmmayo
committed
#3052 - removing supervisor role - WIP
1 parent 71209b6 commit 79f14dc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

service/src/main/java/skills/services/GlobalBadgeRoleService.groovy

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import skills.controller.result.model.BadgeResult
2727
import skills.controller.result.model.UserRoleRes
2828
import skills.services.admin.BadgeAdminService
2929
import skills.services.admin.UserCommunityService
30-
import skills.services.quiz.QuizRoleService
3130
import skills.services.userActions.DashboardAction
3231
import skills.services.userActions.DashboardItem
3332
import skills.services.userActions.UserActionInfo
@@ -48,9 +47,6 @@ class GlobalBadgeRoleService {
4847
@Autowired
4948
UserInfoService userInfoService
5049

51-
@Autowired
52-
QuizRoleService quizRoleService
53-
5450
@Autowired
5551
BadgeAdminService badgeAdminService
5652

@@ -84,8 +80,8 @@ class GlobalBadgeRoleService {
8480
if (currentUser?.toLowerCase() == userId?.toLowerCase()) {
8581
throw new SkillException("Cannot add roles to myself. userId=[${userId}]", ErrorCode.AccessDenied)
8682
}
87-
Boolean addingAsLocalAdmin = adminGroupId == null && roleName == RoleName.ROLE_QUIZ_ADMIN;
88-
if (addingAsLocalAdmin && userRoleRepo.isUserQuizGroupAdmin(userId, badgeId)) {
83+
Boolean addingAsLocalAdmin = adminGroupId == null && roleName == RoleName.ROLE_GLOBAL_BADGE_ADMIN;
84+
if (addingAsLocalAdmin && userRoleRepo.isUserGlobalBadgeAdmin(userId, badgeId)) {
8985
throw new SkillException("User is already part of an Admin Group and cannot be added as a local admin. userId=[${userId}]", ErrorCode.AccessDenied)
9086
}
9187
accessSettingsStorageService.addGlobalAdminUserRoleForUser(userId, badgeResult.badgeId, RoleName.ROLE_GLOBAL_BADGE_ADMIN)
@@ -94,10 +90,10 @@ class GlobalBadgeRoleService {
9490
String userIdForDisplay = userAttrs?.userIdForDisplay ?: userId
9591
userActionsHistoryService.saveUserAction(new UserActionInfo(
9692
action: DashboardAction.Create, item: DashboardItem.UserRole,
97-
itemId: userIdForDisplay, badgeId: badgeResult.badgeId,
93+
itemId: userIdForDisplay,
9894
actionAttributes: [
9995
userRole: roleName,
100-
quizName: badgeResult.name,
96+
badgeName: badgeResult.name,
10197
badgeId: badgeResult.badgeId,
10298
]
10399
))

service/src/main/java/skills/storage/repos/UserRoleRepo.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ interface UserRoleRepo extends CrudRepository<UserRole, Integer> {
6161
@Query(value = '''SELECT DISTINCT 'true' FROM user_roles ur WHERE ur.user_id = ?1 and ur.role_name in ('ROLE_ADMIN_GROUP_MEMBER','ROLE_ADMIN_GROUP_OWNER') and ur.admin_group_id = ?2 ''', nativeQuery = true)
6262
Boolean isUserGroupAdminMemberOrOwner(String userId, String adminGroupId)
6363

64+
@Nullable
65+
@Query('''SELECT DISTINCT 'true' from UserRole ur where ur.userId = ?1 and ur.roleName = 'ROLE_GLOBAL_BADGE_ADMIN' and ur.globalBadgeId = ?2''')
66+
Boolean isUserGlobalBadgeAdmin(String userId, String projectId)
67+
6468
void deleteByQuizIdAndAdminGroupIdAndRoleName(String quizId, String adminGroupId, RoleName roleName)
6569

6670
void deleteByProjectIdAndAdminGroupIdAndRoleName(String quizId, String adminGroupId, RoleName roleName)

0 commit comments

Comments
 (0)