diff --git a/src/main/java/sirius/biz/tenants/TenantUserManager.java b/src/main/java/sirius/biz/tenants/TenantUserManager.java index 3ef340c0c..9a313a206 100644 --- a/src/main/java/sirius/biz/tenants/TenantUserManager.java +++ b/src/main/java/sirius/biz/tenants/TenantUserManager.java @@ -526,7 +526,7 @@ private UserInfo verifyIpRange(WebContext webContext, UserInfo info) { return defaultUser; } - T tenant = account.getTenant().fetchValue(); + T tenant = fetchTenant(account.getTenant().getIdAsString()); if (tenant != null && !tenant.getTenantData().matchesIPRange(webContext)) { return createUserWithLimitedRoles(info, tenant.getTenantData().getRolesToKeepAsSet()); @@ -606,7 +606,8 @@ private UserInfo asUserWithRoles(U account, Set roles, @Nullable Supplie return UserInfo.Builder.createUser(account.getUniqueName()) .withUsername(account.getUserAccountData().getLogin().getUsername()) .withTenantId(String.valueOf(account.getTenant().getId())) - .withTenantName(account.getTenant().fetchValue().getTenantData().getName()) + .withTenantName(fetchTenant(account.getTenant().getIdAsString()).getTenantData() + .getName()) .withLanguage(computeLanguage(null, account.getUniqueName())) .withPermissions(roles) .withSettingsSupplier(user -> getUserSettings(getScopeSettings(), user)) @@ -639,13 +640,12 @@ public UserInfo findUserByCredentials(@Nullable WebContext webContext, String us } U account = result.getUserObject(getUserClass()); + T tenant = fetchTenant(account.getTenant().getIdAsString()); if (account.getUserAccountData().isExternalLoginRequired() && !isWithinInterval(account.getUserAccountData() .getLogin() .getLastExternalLogin(), - account.getTenant() - .fetchValue() - .getTenantData() - .getExternalLoginIntervalDays())) { + tenant.getTenantData() + .getExternalLoginIntervalDays())) { completeAuditLogForUser(auditLog.negative("AuditLog.externalLoginRequired"), account); throw Exceptions.createHandled().withNLSKey("UserAccount.externalLoginMustBePerformed").handle(); } @@ -674,8 +674,7 @@ public UserInfo findUserByCredentials(@Nullable WebContext webContext, String us auditLog.negative("AuditLog.loginRejected") .forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) - .forTenant(String.valueOf(account.getTenant().getId()), - account.getTenant().fetchValue().getTenantData().getName()) + .forTenant(tenant.getIdAsString(), tenant.getTenantData().getName()) .log(); return null; @@ -720,7 +719,7 @@ protected void completeAuditLogForUser(AuditLog.AuditLogBuilder builder, U accou builder.causedByUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forUser(account.getUniqueName(), account.getUserAccountData().getLogin().getUsername()) .forTenant(String.valueOf(account.getTenant().getId()), - account.getTenant().fetchValue().getTenantData().getName()) + fetchTenant(account.getTenant().getIdAsString()).getTenantData().getName()) .log(); } @@ -793,7 +792,7 @@ protected U getUserObject(UserInfo userInfo) { protected UserSettings getUserSettings(UserSettings scopeSettings, UserInfo userInfo) { U user = userInfo.getUserObject(getUserClass()); Config userAccountConfig = user.getUserAccountData().getPermissions().getConfig(); - Config tenantConfig = user.getTenant().fetchValue().getTenantData().getConfig(); + Config tenantConfig = fetchTenant(user.getTenant().getIdAsString()).getTenantData().getConfig(); if (userAccountConfig == null) { if (tenantConfig == null) { @@ -854,7 +853,7 @@ protected boolean isUserStillValid(String userId, WebContext webContext) { } LoginData loginData = user.getUserAccountData().getLogin(); - TenantData tenantData = user.getTenant().fetchValue().getTenantData(); + TenantData tenantData = fetchTenant(user.getTenant().getIdAsString()).getTenantData(); if (loginData.isAccountLocked()) { return false; @@ -968,7 +967,7 @@ protected Set computeRoles(WebContext webContext, String accountUniqueNa } Set roles = computeRoles(user, - user.getTenant().fetchValue(), + fetchTenant(user.getTenant().getIdAsString()), Strings.areEqual(systemTenant, String.valueOf(user.getTenant().getId()))); rolesCache.put(accountUniqueName, Tuple.create(roles, user.getTenant().getUniqueObjectName())); @@ -1043,7 +1042,7 @@ protected String computeLanguage(WebContext webContext, String userId) { return NLS.getDefaultLanguage(); } return Strings.firstFilled(userAccount.getUserAccountData().getLanguage().getValue(), - userAccount.getTenant().fetchValue().getTenantData().getLanguage().getValue(), + fetchTenant(userAccount.getTenant().getIdAsString()).getTenantData().getLanguage().getValue(), NLS.getDefaultLanguage()); } }