topcoder-platform / micro-frontends-forums-app

MIT License
1 stars 1 forks source link

[$75] 'challenge discussion' link is opening vanilla forums #12

Closed sdgun closed 2 years ago

sdgun commented 2 years ago

Steps Create a new challenge Go to challenge details page (ex- https://www.topcoder-dev.com/challenges/9fe92fbd-d495-438a-87be-25d9aa95791c) Click

It opens the page https://vanilla.topcoder-dev.com/categories/9fe92fbd-d495-438a-87be-25d9aa95791c not the MFE page

https://user-images.githubusercontent.com/4592712/145332273-772070cf-74c4-4a86-ba41-a476b3d76553.mp4

sdgun commented 2 years ago

It also doesn't redirect to MFE forums when click links in the email notifications

https://user-images.githubusercontent.com/4592712/145333061-2022c5f2-a42d-49db-8188-d8aa75faf52b.mp4

jmgasper commented 2 years ago

Challenge https://www.topcoder.com/challenges/242dfc8a-b989-4a6d-96d7-4b7d80ac5013 has been created for this ticket.

This is an automated message for ghostar via Topcoder X

jmgasper commented 2 years ago

Challenge https://www.topcoder.com/challenges/242dfc8a-b989-4a6d-96d7-4b7d80ac5013 has been assigned to obog.

This is an automated message for ghostar via Topcoder X

jmgasper commented 2 years ago

@atelomycterus - Can you check the redirect for the category page please? I can fix the link for the challenges.

jmgasper commented 2 years ago

Hmmm... Actually, looks like the challenge forum processor is using the category.url value returned by the Vanilla API, which is pointing to vanilla.topcoder-dev. We may have to tweak the challenge forum processor to handle this a bit more formally, so I'll just add that to the "TODO" list. As long as the redirect is working, that's enough for now.

atelomycterus commented 2 years ago

@jmgasper The issue happens sporadically due to Topocder Auth0 iframe. So setupAuth0withRedirect.js and Vanilla embed_local.js are running. The first one uses JavaScript's window.onload and the second one jQuery's $(document).ready() method. Whether or not a redirect goes through depends on which script with the redirect is executed first. So we need to fix Vanilla entry controller + set correct {target} for Sign/SignOut Url if embedded Vanilla. Now it's is always vanilla.topcoder-dev.com. It should be platform.topcoder-dev.com if Vanilla is embedded.

Keep you updated in it.

Some details

The request initiator chain, no redirect to MFE page: image

This frame is added by setupAuth0withRedirect.js and executed on JavaScript's window.onload. Return url of Auth0 is vanilla.topocder-dev.com. So user is not redirected to MFE page.

<script>function prepareFrame() {
    var ifrm = document.createElement("iframe");
    ifrm.setAttribute("src", "https://accounts-auth0.topcoder-dev.com/");
    ifrm.style.width = "0px"; 
    ifrm.style.height = "0px";
    document.body.appendChild(ifrm);
 } 
window.onload = prepareFrame;</script>

Embed_local.js ( in jQuery's $(document).ready()) checks if Vanilla is embedded or not. If Vanilla is embedded then go to MFE page:

The request initiator chain: image

atelomycterus commented 2 years ago

@jmgasper Please apply PR-https://github.com/topcoder-platform/forums/pull/646. Thanks!

Settings

Use {target} for 'retUrl' in Topcoder Plugin.

if 'Garden.Embed.Allow' is true + 'Garden.Embed.RemoteUrl' is configured then the host of 'Garden.Embed.RemoteUrl' is used in {target}

Example: SignIn - https://accounts-auth0.topcoder-dev.com/?retUrl={target} SignOut - https://accounts-auth0.topcoder-dev.com/?logout=true&retUrl={target} image

jmgasper commented 2 years ago

Looks good, thanks!

jmgasper commented 2 years ago

Payment task has been updated: https://www.topcoder.com/challenges/242dfc8a-b989-4a6d-96d7-4b7d80ac5013 Payments Complete Winner: obog Copilot: ghostar Challenge 242dfc8a-b989-4a6d-96d7-4b7d80ac5013 has been paid and closed.

This is an automated message for ghostar via Topcoder X