fix: properly block org transfers

This commit is contained in:
MiniDigger | Martin 2023-04-22 23:25:18 +02:00
parent aff7104562
commit 5d4a526a92

View File

@ -65,10 +65,13 @@ public abstract class InviteService<LC extends LogContext<?, LC>, R extends Role
@Transactional
public void sendTransferRequest(final String user, final J joinable) {
final UserTable userTable = this.userDAO.getUserTable(user);
// TODO transfer project to organization (and divert invite to owner)
if (userTable == null || userTable.isOrganization()) {
if (userTable == null) {
throw new HangarApiException(this.errorPrefix + "invalidUser", user);
}
// TODO transfer project to organization (and divert invite to owner)
if (userTable.getEmail().endsWith(this.config.org.dummyEmailDomain())) {
throw new HangarApiException("Org transfers are not implemented yet");
}
final List<RT> ownerRoles = this.roleService.getRoles(joinable.getId(), this.getOwnerRole());
if (ownerRoles.stream().anyMatch(rt -> rt.getUserId() != joinable.getOwnerId())) {