From 4fa00e27aa13aa7ac1a5bdecb7c3fef58181ac69 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 8 Dec 2023 13:49:03 +0200 Subject: [PATCH] fix portal oidcs redirect url --- .../views/settings/fields/oidc-redirect-uri.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/src/views/settings/fields/oidc-redirect-uri.js b/client/src/views/settings/fields/oidc-redirect-uri.js index 99cbcd4bb6..82332bf6de 100644 --- a/client/src/views/settings/fields/oidc-redirect-uri.js +++ b/client/src/views/settings/fields/oidc-redirect-uri.js @@ -47,7 +47,7 @@ define('views/settings/fields/oidc-redirect-uri', ['views/fields/varchar'], func portalCollection: null, data: function () { - let isNotEmpty = this.model.entityType !== 'AuthenticationProvider' || + const isNotEmpty = this.model.entityType !== 'AuthenticationProvider' || this.portalCollection; return { @@ -60,7 +60,7 @@ define('views/settings/fields/oidc-redirect-uri', ['views/fields/varchar'], func * @protected */ copyToClipboard: function () { - let value = this.getValueForDisplay(); + const value = this.getValueForDisplay(); navigator.clipboard.writeText(value).then(() => { Espo.Ui.success(this.translate('Copied to clipboard')); @@ -75,14 +75,21 @@ define('views/settings/fields/oidc-redirect-uri', ['views/fields/varchar'], func return this.portalCollection.models .map(model => { - let url = (model.get('url') || '').replace(/\/+$/, ''); + const file = 'oauth-callback.php' + const url = (model.get('url') || '').replace(/\/+$/, '') + `/${file}`; - return url + '/oauth-callback.php'; + const part = `/portal/${model.id}/oauth-callback.php`; + + if (!url.endsWith(part)) { + return url; + } + + return url.slice(0, - part.length) + `/portal/${file}`; }) .join('\n'); } - let siteUrl = (this.getConfig().get('siteUrl') || '').replace(/\/+$/, ''); + const siteUrl = (this.getConfig().get('siteUrl') || '').replace(/\/+$/, ''); return siteUrl + '/oauth-callback.php'; },