Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

set role default value #416

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public AccessResponseDTO createAccessRequestToProject(UUID id, AccessRequestDTO
}
User user = userService.getUserEntityByUsername(accessRequestDTO.getUsername());
if (isNull(accessRequestDTO.getRole())) {
throw new ResourceNotFoundException("Role cannot be null");
accessRequestDTO.setRole(com.redhat.parodos.project.enums.Role.DEVELOPER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why this is the correct default role?
Can you please document this behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OWNER, ADMIN and DEVELOPER are the 3 possible roles that a user can have in a project at the moment.
By default, DEVELOPER is used for an access request when the role is not provided in the request payload.
As the UI doesn't support or allow the requester to specify the role (ADMIN or DEVELOPER) for a user, DEVELOPER is currently used as default.
I'll open a PR today to document the entire behaviour :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation!

}
Role role = roleRepository.findByNameIgnoreCase(accessRequestDTO.getRole().name()).orElseThrow(
() -> new ResourceNotFoundException(ResourceType.ROLE, IDType.NAME, accessRequestDTO.getRole().name()));
Expand Down