diff --git a/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/UnitAclController.kt b/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/UnitAclController.kt index 4f2a34c7e9..4bb2fdf01b 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/UnitAclController.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/daycare/controllers/UnitAclController.kt @@ -620,10 +620,10 @@ class UnitAclController( ) { db.transaction { tx -> if ( - !tx.hasRoleInAnyUnitWithProviderType( + !tx.hasRoleInAnyUnitWithProviderTypes( job.employeeId, UserRole.UNIT_SUPERVISOR, - ProviderType.MUNICIPAL, + setOf(ProviderType.MUNICIPAL, ProviderType.MUNICIPAL_SCHOOL), ) ) { tx.deletePersonalDevices(job.employeeId) diff --git a/service/src/main/kotlin/fi/espoo/evaka/shared/auth/AclQueries.kt b/service/src/main/kotlin/fi/espoo/evaka/shared/auth/AclQueries.kt index 7fda459df6..7cfadc87e2 100644 --- a/service/src/main/kotlin/fi/espoo/evaka/shared/auth/AclQueries.kt +++ b/service/src/main/kotlin/fi/espoo/evaka/shared/auth/AclQueries.kt @@ -74,10 +74,10 @@ fun Database.Read.hasAnyDaycareAclRow(employeeId: EmployeeId): Boolean = } .exactlyOne() -fun Database.Read.hasRoleInAnyUnitWithProviderType( +fun Database.Read.hasRoleInAnyUnitWithProviderTypes( employeeId: EmployeeId, role: UserRole, - providerType: ProviderType, + providerTypes: Set, ): Boolean = createQuery { sql( @@ -88,7 +88,7 @@ SELECT EXISTS ( WHERE acl.employee_id = ${bind(employeeId)} AND acl.role = ${bind(role)} AND - d.provider_type = ${bind(providerType)} + d.provider_type = ANY (${bind(providerTypes)}) ) """ )