fix: allow slug reuse after tenant soft-delete
All checks were successful
CI / build (push) Successful in 59s
CI / docker (push) Successful in 39s

existsBySlug found DELETED records, blocking slug reuse. Changed to
existsBySlugAndStatusNot(slug, DELETED) so deleted tenant slugs can
be reclaimed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-10 07:25:49 +02:00
parent 5ed33807d8
commit ebdb4f9450
3 changed files with 6 additions and 5 deletions

View File

@@ -13,4 +13,5 @@ public interface TenantRepository extends JpaRepository<TenantEntity, UUID> {
Optional<TenantEntity> findByLogtoOrgId(String logtoOrgId);
List<TenantEntity> findByStatus(TenantStatus status);
boolean existsBySlug(String slug);
boolean existsBySlugAndStatusNot(String slug, TenantStatus status);
}

View File

@@ -24,7 +24,7 @@ public class TenantService {
}
public TenantEntity create(CreateTenantRequest request, UUID actorId) {
if (tenantRepository.existsBySlug(request.slug())) {
if (tenantRepository.existsBySlugAndStatusNot(request.slug(), TenantStatus.DELETED)) {
throw new IllegalArgumentException("Slug already taken");
}