From a5e69fe7773eabbec9556d7f3dd17c9d200ea48a Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 3 Apr 2024 10:24:51 +0300 Subject: [PATCH] bug fix --- .../eu/eudat/interceptors/tenant/TenantInterceptor.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/interceptors/tenant/TenantInterceptor.java b/dmp-backend/web/src/main/java/eu/eudat/interceptors/tenant/TenantInterceptor.java index 59b59d033..ebf5a7059 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/interceptors/tenant/TenantInterceptor.java +++ b/dmp-backend/web/src/main/java/eu/eudat/interceptors/tenant/TenantInterceptor.java @@ -138,6 +138,10 @@ public class TenantInterceptor implements WebRequestInterceptor { .unwrap(Session.class) .enableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER); } + UserTenantRolesCacheService.UserTenantRolesCacheValue cacheValue = this.userTenantRolesCacheService.lookup(this.userTenantRolesCacheService.buildKey(this.userScope.getUserId(), this.tenantScope.isDefaultTenant() ? UUID.fromString("00000000-0000-0000-0000-000000000000") : this.tenantScope.getTenant())); + if (cacheValue == null || !this.userRolesSynced(cacheValue.getRoles())) { + this.syncUserWithClaims(); + } } else { if (isAllowedNoTenant || this.isWhiteListedEndpoint(request)) { tenantScope.setTenant(null, null); @@ -146,11 +150,6 @@ public class TenantInterceptor implements WebRequestInterceptor { throw new MyForbiddenException(this.errors.getTenantNotAllowed().getCode(), this.errors.getTenantNotAllowed().getMessage()); } } - - UserTenantRolesCacheService.UserTenantRolesCacheValue cacheValue = this.userTenantRolesCacheService.lookup(this.userTenantRolesCacheService.buildKey(this.userScope.getUserId(), this.tenantScope.isDefaultTenant() ? UUID.fromString("00000000-0000-0000-0000-000000000000") : this.tenantScope.getTenant())); - if (cacheValue == null || !this.userRolesSynced(cacheValue.getRoles())) { - this.syncUserWithClaims(); - } } else { if (!isAllowedNoTenant) { if (!this.isWhiteListedEndpoint(request)) {