Skip to content

Commit 74967d0

Browse files
author
Sachin Maheshwari
committed
plat-700, discord redirect
1 parent dc601e5 commit 74967d0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

web-assets/js/setupAuth0WithRedirect.js

Lines changed: 16 additions & 3 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,10 +238,22 @@ const authSetup = function () {
237238
}
238239

239240
const redirectToApp = function () {
240-
logger("redirect to app", appUrl);
241-
if (appUrl) {
242-
window.location = appUrl;
241+
logger("redirect to app", appUrl);
242+
if (appUrl) {
243+
if (appUrl.indexOf(discord_pattern) > -1) {
244+
try {
245+
var newUrl = new URL(appUrl);
246+
window.location = newUrl.searchParams.append(
247+
"token",
248+
getCookie(v3JWTCookie)
249+
).href;
250+
} catch (e) {
251+
logger("Error in redirect to discord", e.message)
252+
}
253+
} else {
254+
window.location = appUrl;
243255
}
256+
}
244257
};
245258

246259
const postLogin = function () {

0 commit comments

Comments
 (0)