diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f8a712..5a31496 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,8 +70,6 @@ workflows: branches: only: - dev - - hotfix/resendActivationEmail - - feat/plat-320 # Production builds are exectuted only on tagged commits to the # master branch. diff --git a/web-assets/js/setupAuth0WithRedirect.js b/web-assets/js/setupAuth0WithRedirect.js index b6404b7..8a61555 100644 --- a/web-assets/js/setupAuth0WithRedirect.js +++ b/web-assets/js/setupAuth0WithRedirect.js @@ -46,6 +46,7 @@ const authSetup = function () { const mode = qs['mode'] || 'signIn'; let returnAppUrl = handleSpecificReturnUrl(qs['retUrl'], 'retUrl'); let appUrl = qs['appUrl'] || false; + const discord_pattern = 'https://tc-topbot-1.herokuapp.com/'; if (utmSource && (utmSource != 'undefined') && @@ -237,17 +238,17 @@ const authSetup = function () { } const redirectToApp = function () { - logger("redirect to app", appUrl); - if (appUrl) { - window.location = appUrl; - } + logger("redirect to app", appUrl); + if (appUrl) { + hookRedirect(appUrl); + } }; const postLogin = function () { if (isLoggedIn() && returnAppUrl) { auth0.isAuthenticated().then(function (isAuthenticated) { if (isAuthenticated) { - window.location = returnAppUrl; + hookRedirect(returnAppUrl); } else { login(); // old session exist case } @@ -703,6 +704,24 @@ const authSetup = function () { } }; + function hookRedirect(redirect_url) { + if (redirect_url && (redirect_url.indexOf(discord_pattern) > -1)) { + try { + var newUrl = new URL(redirect_url); + newUrl.searchParams.append( + "token", + getCookie(v3JWTCookie) + ); + window.location = newUrl.href; + } catch (e) { + logger("Error in redirecting to discord", e.message); + window.location = redirect_url; + } + } else { + window.location = redirect_url; + } + } + // execute init(); };