Skip to content

Commit b675148

Browse files
author
sachin-maheshwari
authored
Merge pull request #304 from topcoder-platform/jira-plat-700
Jira Plat 700
2 parents dc601e5 + f0df564 commit b675148

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

.circleci/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ workflows:
7070
branches:
7171
only:
7272
- dev
73-
- hotfix/resendActivationEmail
74-
- feat/plat-320
7573

7674
# Production builds are exectuted only on tagged commits to the
7775
# master branch.

web-assets/js/setupAuth0WithRedirect.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const authSetup = function () {
4646
const mode = qs['mode'] || 'signIn';
4747
let returnAppUrl = handleSpecificReturnUrl(qs['retUrl'], 'retUrl');
4848
let appUrl = qs['appUrl'] || false;
49+
const discord_pattern = 'https://tc-topbot-1.herokuapp.com/';
4950

5051
if (utmSource &&
5152
(utmSource != 'undefined') &&
@@ -237,17 +238,17 @@ const authSetup = function () {
237238
}
238239

239240
const redirectToApp = function () {
240-
logger("redirect to app", appUrl);
241-
if (appUrl) {
242-
window.location = appUrl;
243-
}
241+
logger("redirect to app", appUrl);
242+
if (appUrl) {
243+
hookRedirect(appUrl);
244+
}
244245
};
245246

246247
const postLogin = function () {
247248
if (isLoggedIn() && returnAppUrl) {
248249
auth0.isAuthenticated().then(function (isAuthenticated) {
249250
if (isAuthenticated) {
250-
window.location = returnAppUrl;
251+
hookRedirect(returnAppUrl);
251252
} else {
252253
login(); // old session exist case
253254
}
@@ -703,6 +704,24 @@ const authSetup = function () {
703704
}
704705
};
705706

707+
function hookRedirect(redirect_url) {
708+
if (redirect_url && (redirect_url.indexOf(discord_pattern) > -1)) {
709+
try {
710+
var newUrl = new URL(redirect_url);
711+
newUrl.searchParams.append(
712+
"token",
713+
getCookie(v3JWTCookie)
714+
);
715+
window.location = newUrl.href;
716+
} catch (e) {
717+
logger("Error in redirecting to discord", e.message);
718+
window.location = redirect_url;
719+
}
720+
} else {
721+
window.location = redirect_url;
722+
}
723+
}
724+
706725
// execute
707726
init();
708727
};

0 commit comments

Comments
 (0)