Skip to content

Commit

Permalink
Add a missing provider type check
Browse files Browse the repository at this point in the history
  • Loading branch information
akheron committed Dec 19, 2024
1 parent d68ee4f commit 9b93dc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import fi.espoo.evaka.shared.auth.clearDaycareGroupAcl
import fi.espoo.evaka.shared.auth.deleteDaycareAclRow
import fi.espoo.evaka.shared.auth.getDaycareAclRows
import fi.espoo.evaka.shared.auth.hasAnyDaycareAclRow
import fi.espoo.evaka.shared.auth.hasRoleInAnyUnitWithProviderType
import fi.espoo.evaka.shared.auth.hasRoleInAnyUnitWithProviderTypes
import fi.espoo.evaka.shared.auth.insertDaycareAclRow
import fi.espoo.evaka.shared.auth.insertDaycareGroupAcl
import fi.espoo.evaka.shared.db.Database
Expand Down Expand Up @@ -632,10 +632,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ fun Database.Read.hasAnyDaycareAclRow(employeeId: EmployeeId): Boolean =
}
.exactlyOne<Boolean>()

fun Database.Read.hasRoleInAnyUnitWithProviderType(
fun Database.Read.hasRoleInAnyUnitWithProviderTypes(
employeeId: EmployeeId,
role: UserRole,
providerType: ProviderType,
providerTypes: Set<ProviderType>,
): Boolean =
createQuery {
sql(
Expand All @@ -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)})
)
"""
)
Expand Down

0 comments on commit 9b93dc8

Please sign in to comment.