mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +00:00
revert party id -> org id (#39)
Co-authored-by: ggmaleva <ggmaleva@yandex.ru>
This commit is contained in:
parent
92545a9076
commit
d18e24fc78
@ -306,10 +306,10 @@ public class OrganizationService {
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public String getPartyByInvitationToken(String token) {
|
||||
public String getOrgIdByInvitationToken(String token) {
|
||||
InvitationEntity invitationEntity = invitationService.findByToken(token);
|
||||
OrganizationEntity organizationEntity = findById(invitationEntity.getOrganizationId());
|
||||
return organizationEntity.getParty();
|
||||
return organizationEntity.getId();
|
||||
}
|
||||
|
||||
public OrganizationEntity findById(String orgId) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.vality.orgmanager.service;
|
||||
|
||||
import dev.vality.orgmanager.config.properties.AccessProperties;
|
||||
import dev.vality.orgmanager.entity.OrganizationEntity;
|
||||
import dev.vality.orgmanager.exception.AccessDeniedException;
|
||||
import dev.vality.orgmanager.service.dto.BouncerContextDto;
|
||||
import dev.vality.orgmanager.service.dto.InvitationDto;
|
||||
@ -45,15 +44,10 @@ public class ResourceAccessServiceImpl implements ResourceAccessService {
|
||||
}
|
||||
String callerMethodName = StackUtils.getCallerMethodName();
|
||||
BouncerContextDto bouncerContext = buildBouncerContextDto(resource, callerMethodName);
|
||||
if (Objects.nonNull(resource.getOrgId())) {
|
||||
log.info("Get organization by orgId: {}", resource.getOrgId());
|
||||
OrganizationEntity organization = organizationService.findById(resource.getOrgId());
|
||||
bouncerContext.setOrganizationId(organization.getParty());
|
||||
}
|
||||
if (Objects.nonNull(resource.getInvitationToken())) {
|
||||
log.info("Get organization by invitation token");
|
||||
String party = organizationService.getPartyByInvitationToken(resource.getInvitationToken());
|
||||
bouncerContext.setOrganizationId(party);
|
||||
String orgId = organizationService.getOrgIdByInvitationToken(resource.getInvitationToken());
|
||||
bouncerContext.setOrganizationId(orgId);
|
||||
}
|
||||
if (Objects.nonNull(resource.getMemberRoleId())) {
|
||||
String memberRoleId = resource.getMemberRoleId();
|
||||
|
@ -63,12 +63,10 @@ class ResourceAccessServiceImplTest {
|
||||
|
||||
@Test
|
||||
void checkOrgRights() {
|
||||
String orgId = TestObjectFactory.randomString();
|
||||
ResourceDto resource = ResourceDto.builder()
|
||||
.orgId(orgId)
|
||||
.orgId(TestObjectFactory.randomString())
|
||||
.build();
|
||||
when(bouncerService.havePrivileges(any(BouncerContextDto.class))).thenReturn(true);
|
||||
when(organizationService.findById(orgId)).thenReturn(TestObjectFactory.buildOrganization());
|
||||
|
||||
assertDoesNotThrow(() -> resourceAccessService.checkRights(resource));
|
||||
}
|
||||
@ -79,7 +77,7 @@ class ResourceAccessServiceImplTest {
|
||||
.invitationToken(TestObjectFactory.randomString())
|
||||
.build();
|
||||
when(bouncerService.havePrivileges(any(BouncerContextDto.class))).thenReturn(true);
|
||||
when(organizationService.getPartyByInvitationToken(resource.getInvitationToken()))
|
||||
when(organizationService.getOrgIdByInvitationToken(resource.getInvitationToken()))
|
||||
.thenThrow(new ResourceNotFoundException());
|
||||
|
||||
assertThrows(ResourceNotFoundException.class,
|
||||
@ -98,13 +96,11 @@ class ResourceAccessServiceImplTest {
|
||||
|
||||
@Test
|
||||
void checkMemberRights() {
|
||||
String orgId = TestObjectFactory.randomString();
|
||||
ResourceDto resource = ResourceDto.builder()
|
||||
.orgId(orgId)
|
||||
.orgId(TestObjectFactory.randomString())
|
||||
.memberId(TestObjectFactory.randomString())
|
||||
.build();
|
||||
when(bouncerService.havePrivileges(any(BouncerContextDto.class))).thenReturn(true);
|
||||
when(organizationService.findById(orgId)).thenReturn(TestObjectFactory.buildOrganization());
|
||||
|
||||
assertDoesNotThrow(() -> resourceAccessService.checkRights(resource));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user