This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 0628aabc authored by Daniel Crazzolara's avatar Daniel Crazzolara
Browse files

Changed to 'only MAINTAINERS' can import

parent dcbfd616
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
...@@ -297,13 +297,13 @@ public class GitlabService { ...@@ -297,13 +297,13 @@ public class GitlabService {
/** /**
* Used to retrieve all Gitlab groups where the current user * Used to retrieve all Gitlab groups where the current user
* has at least a DEVELOPER membership * has at least a MAINTAINER membership
* *
* @return List of all groups with at least DEVELOPER membership * @return List of all groups with at least MAINTAINER membership
* @throws AuthenticationException * @throws AuthenticationException
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Group> getAllGroupsWithAtLeastDeveloperRole() throws AuthenticationException, GitLabApiException { public List<Group> getAllGroupsWithAtLeastMaintainerRole() throws AuthenticationException, GitLabApiException {
UserApi userApi = gitLabRepository.getGitLabApi(tokenProvider.getGitLabAccessInfo()).getUserApi(); UserApi userApi = gitLabRepository.getGitLabApi(tokenProvider.getGitLabAccessInfo()).getUserApi();
GroupApi groupApi = gitLabRepository.getGitLabApi(tokenProvider.getGitLabAccessInfo()).getGroupApi(); GroupApi groupApi = gitLabRepository.getGitLabApi(tokenProvider.getGitLabAccessInfo()).getGroupApi();
Integer userId = userApi.getCurrentUser().getId(); Integer userId = userApi.getCurrentUser().getId();
...@@ -312,7 +312,7 @@ public class GitlabService { ...@@ -312,7 +312,7 @@ public class GitlabService {
List<Group> groups = getGroups(); List<Group> groups = getGroups();
groups = groups.stream().filter(group -> { groups = groups.stream().filter(group -> {
try { try {
return groupApi.getMember(group.getId(), userId, true).getAccessLevel().value >= 30; return groupApi.getMember(group.getId(), userId, true).getAccessLevel().value >= 40;
} catch (GitLabApiException e) { } catch (GitLabApiException e) {
log.warn("Could not retrieve membership of user [{}] for group [{}]. Skipping..", userId, group.getId()); log.warn("Could not retrieve membership of user [{}] for group [{}]. Skipping..", userId, group.getId());
} }
......
...@@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.naming.AuthenticationException; import javax.naming.AuthenticationException;
import java.nio.file.attribute.GroupPrincipal;
import java.util.List; import java.util.List;
@RestController @RestController
...@@ -35,7 +34,7 @@ public class GitlabResource { ...@@ -35,7 +34,7 @@ public class GitlabResource {
@GetMapping("/groups") @GetMapping("/groups")
public ResponseEntity<List<Group>> getUserGroups() throws GitLabApiException { public ResponseEntity<List<Group>> getUserGroups() throws GitLabApiException {
try { try {
return ResponseEntity.ok(gitlabService.getAllGroupsWithAtLeastDeveloperRole()); return ResponseEntity.ok(gitlabService.getAllGroupsWithAtLeastMaintainerRole());
} catch (AuthenticationException ae) { } catch (AuthenticationException ae) {
return ResponseEntity.status(401).body(null); return ResponseEntity.status(401).body(null);
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment