From a138662a3b31280e884ef3e250ee07dabc51dd9f Mon Sep 17 00:00:00 2001 From: AlixH Date: Wed, 8 Dec 2021 11:48:27 +0100 Subject: [PATCH] Fixed tenants logos --- src/provider/CentralServerProvider.tsx | 14 +++++--------- src/screens/auth/login/Login.tsx | 11 ++++++----- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/provider/CentralServerProvider.tsx b/src/provider/CentralServerProvider.tsx index ea84b3f69..b319fef3f 100644 --- a/src/provider/CentralServerProvider.tsx +++ b/src/provider/CentralServerProvider.tsx @@ -152,7 +152,7 @@ export default class CentralServerProvider { let tenantLogo = this.tenantLogosCache.get(tenant.subdomain); if (!tenantLogo) { // Call backend - const result = await this.axiosInstance.get(this.buildUtilRestEndpointUrl(ServerRoute.REST_TENANT_LOGO), { + const result = await this.axiosInstance.get(this.buildUtilRestEndpointUrl(ServerRoute.REST_TENANT_LOGO, null, tenant), { headers: this.buildHeaders(), responseType: 'arraybuffer', params: { @@ -1070,12 +1070,8 @@ export default class CentralServerProvider { return this.tenant?.endpoint + '/v1/api'; } - private buildUtilRestServerURL(): string { - return this.tenant?.endpoint + '/v1/util'; - } - - private buildCentralRestServerServiceUtilURL(tenant: TenantConnection): string { - return tenant?.endpoint + '/client/util'; + private buildUtilRestServerURL(tenant?: TenantConnection): string { + return (tenant?.endpoint ?? this.tenant?.endpoint) + '/v1/util'; } private buildCentralRestServerServiceSecuredURL(): string { @@ -1092,7 +1088,7 @@ export default class CentralServerProvider { return `${urlPrefix}/${resolvedUrlPattern}`; } - public buildUtilRestEndpointUrl(urlPatternAsString: ServerRoute, params: { [name: string]: string | number | null } = {}): string { - return this.buildRestEndpointUrl(urlPatternAsString, params, this.buildUtilRestServerURL()); + public buildUtilRestEndpointUrl(urlPatternAsString: ServerRoute, params: { [name: string]: string | number | null } = {}, tenant?: TenantConnection): string { + return this.buildRestEndpointUrl(urlPatternAsString, params, this.buildUtilRestServerURL(tenant)); } } diff --git a/src/screens/auth/login/Login.tsx b/src/screens/auth/login/Login.tsx index f528d5082..1cbd64316 100644 --- a/src/screens/auth/login/Login.tsx +++ b/src/screens/auth/login/Login.tsx @@ -172,6 +172,7 @@ export default class Login extends BaseScreen { this.tenants = await this.centralServerProvider.getTenants(); this.setState({ tenantSubDomain: null, + tenantLogo: null, tenantName: I18n.t('authentication.tenant'), email: null, password: null @@ -286,8 +287,8 @@ export default class Login extends BaseScreen { this.setState({ email: credentials.email, password: credentials.password, - tenantSubDomain: tenant.subdomain, - tenantName: tenant.name, + tenantSubDomain: tenant?.subdomain, + tenantName: tenant?.name, tenantLogo }); } else { @@ -295,8 +296,8 @@ export default class Login extends BaseScreen { this.setState({ email: null, password: null, - tenantSubDomain: tenant.subdomain, - tenantName: tenant.name, + tenantSubDomain: tenant?.subdomain, + tenantName: tenant?.name, tenantLogo }); } @@ -368,7 +369,7 @@ export default class Login extends BaseScreen {
{this.state.errorTenantSubDomain &&