Preventing the JS to dynamically load the Hyperlink

AI-generated summary

The discussion revolves around preventing JavaScript from dynamically loading a hyperlink. JustinBack is designing a mix between SSO and GitHub authentication and uses a widget to add a GitHub button to the navbar. However, the JavaScript redirects the button to a non-existent site.

Falco explains that having SSO and social logins simultaneously is not supported and suggests alternative solutions. JustinBack mentions that the parent SSO site already has GitHub login but with some caveats, making it easier to implement with Discourse. Ultimately, JustinBack resolves the issue by using a PHP script to redirect to the GitHub authentication page, making the button functional.

Hello everybody,

Currently designing a mix between SSO and GitHub auth.
When SSO is enabled all other login methods disappear, thats why I use a widget to add a GitHub button to the navbar, however the JS likes to catch on the button and redirect me dynamically to a site that doesn’t exist!

<script type="text/discourse-plugin" version="0.4">
const { iconNode } = require("discourse-common/lib/icon-library");
if(!Discourse.User.current()) {
    api.decorateWidget('header-buttons:before', helper => {
        return helper.attach('link', {
            href: '/auth/github',
            rawLabel: "Login with GitHub",
            title: "Login with GitHub",
            icon: "github",
            className: "btn btn-primary btn-small login-button"
        });
    });
}
</script>

The snippet works great and displays it properly. Is there anything I can do without editing the core of discourse? Such as e.preventdefault?

As I can embed only one image, here is the redirect error.

You can’t have SSO and social logins at the same time. That’s not a supported state.

Either use two login methods (moving your current SSO to oauth2 for example) or implement the GitHub login in the parent SSO site.

The parent SSO site has github login already (with a few caveats thats why its easier for with discourse). Anyways, I have solved my problem by having a php script redirect me back to /auth/github. Everything works fine with that button now.