Remove org model; make AppUser global with super admin
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s

This commit is contained in:
androidlover5842
2026-01-26 22:33:59 +05:30
parent bf87d329d4
commit 1400451bfe
26 changed files with 101 additions and 362 deletions

View File

@@ -1,5 +1,6 @@
package com.android.trisolarisserver.component
import com.android.trisolarisserver.repo.AppUserRepo
import com.android.trisolarisserver.repo.PropertyUserRepo
import com.android.trisolarisserver.models.property.Role
import org.springframework.security.access.AccessDeniedException
@@ -8,14 +9,19 @@ import java.util.UUID
@Component
class PropertyAccess(
private val repo: PropertyUserRepo
private val repo: PropertyUserRepo,
private val appUserRepo: AppUserRepo
) {
fun requireMember(propertyId: UUID, userId: UUID) {
val user = appUserRepo.findById(userId).orElse(null)
if (user?.superAdmin == true) return
if (!repo.existsByIdPropertyIdAndIdUserId(propertyId, userId))
throw AccessDeniedException("No access to property")
}
fun requireAnyRole(propertyId: UUID, userId: UUID, vararg roles: Role) {
val user = appUserRepo.findById(userId).orElse(null)
if (user?.superAdmin == true) return
if (!repo.hasAnyRole(propertyId, userId, roles.toSet()))
throw AccessDeniedException("Missing role")
}