From e5dd6d54ed8ee6676af12dea0b640445a14cda8d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 29 Jan 2024 09:55:27 +0800 Subject: [PATCH] Make sure getAbpApplicationConfiguration is called --- .../wwwroot/swagger/ui/abp.swagger.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js b/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js index 23e9420145..07deea114b 100644 --- a/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js +++ b/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js @@ -14,8 +14,6 @@ var abp = abp || {}; var requestInterceptor = configObject.requestInterceptor; var responseInterceptor = configObject.responseInterceptor; - - getAbpApplicationConfiguration(); configObject.requestInterceptor = async function (request) { @@ -29,17 +27,19 @@ var abp = abp || {}; }); firstRequest = false; } + // Intercept .well-known request when the discoveryEndpoint is provided if (!firstRequest && oidcDiscoveryEndpoint.length !== 0 && request.url.includes(".well-known/openid-configuration")) { + if (oidcDiscoveryEndpoint.endsWith(".well-known/openid-configuration")) { - request.url = replaceTenantPlaceHolder(oidcDiscoveryEndpoint); + request.url = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint); console.log(request.url); return; } if (!oidcDiscoveryEndpoint.endsWith("/")) { oidcDiscoveryEndpoint += "/" } - request.url = replaceTenantPlaceHolder(oidcDiscoveryEndpoint) + ".well-known/openid-configuration"; + request.url = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint) + ".well-known/openid-configuration"; console.log(request.url); } @@ -84,7 +84,11 @@ var abp = abp || {}; return response; }; - function replaceTenantPlaceHolder(url) { + async function replaceTenantPlaceHolder(url) { + + if(!abp.currentTenant){ + await getAbpApplicationConfiguration(); + } url.replace(tenantPlaceHolders[0], abp.currentTenant.id); url.replace(tenantPlaceHolders[1], abp.currentTenant.name); @@ -99,7 +103,7 @@ var abp = abp || {}; } function getAbpApplicationConfiguration() { - fetch(`${abp.appPath}api/abp/application-configuration`).then(response => response.json()).then(data => { + return fetch(`${abp.appPath}api/abp/application-configuration`).then(response => response.json()).then(data => { abp.currentTenant = data.currentTenant; }); }