Preventing the JS to dynamically load the Hyperlink

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"

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.

1 Like