Skip to content

Commit b81bf55

Browse files
committed
First phase
1 parent 25a69f3 commit b81bf55

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

openaev-api/src/main/java/io/openaev/config/security/SecurityService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
import io.openaev.database.model.Tenant;
88
import io.openaev.database.model.User;
9+
import io.openaev.database.repository.TenantRepository;
910
import io.openaev.database.repository.UserRepository;
1011
import io.openaev.service.UserMappingService;
1112
import io.openaev.service.UserService;
12-
import io.openaev.service.tenants.TenantService;
1313
import io.openaev.service.user_events.UserEventService;
1414
import jakarta.persistence.EntityNotFoundException;
1515
import jakarta.validation.constraints.NotBlank;
@@ -19,7 +19,6 @@
1919
import java.util.UUID;
2020
import lombok.RequiredArgsConstructor;
2121
import lombok.extern.slf4j.Slf4j;
22-
import org.springframework.context.annotation.Lazy;
2322
import org.springframework.core.env.Environment;
2423
import org.springframework.stereotype.Service;
2524

@@ -41,7 +40,7 @@ public class SecurityService {
4140
private final UserMappingService userMappingService;
4241
private final Environment env;
4342
private final UserEventService userEventService;
44-
private final @Lazy TenantService tenantService;
43+
private final TenantRepository tenantRepository;
4544

4645
public User userManagement(
4746
String emailAttribute,
@@ -115,7 +114,11 @@ private void attachTenant(String registrationId, User user) {
115114
return;
116115
}
117116
try {
118-
Tenant tenant = tenantService.findById(tenantId);
117+
Tenant tenant =
118+
tenantRepository
119+
.findById(tenantId)
120+
.orElseThrow(() -> new EntityNotFoundException("Tenant not found: " + tenantId));
121+
;
119122
user.getTenants().add(tenant);
120123
} catch (EntityNotFoundException e) {
121124
log.warn("SSO tenant ID '{}' configured but not found in database", tenantId);

0 commit comments

Comments
 (0)