# 防止 JS 动态加载超链接

**URL:** https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683
**Category:** Development
**Tags:** unsupported-install
**Created:** [2019年三月5日 01:57 UTC](https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683 "2019-03-05T01:57:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [2019年三月5日 01:57 UTC](https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683/1 "2019-03-05T01:57:59Z")

</div>

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>

```

![](https://global.discourse-cdn.com/meta/original/3X/b/d/bdd8f0aba8c08364da9fbb88e27a5a448cd73d0b.png) The snippet works great and displays it properly. Is there anything I can do without editing the core of discourse? Such as e.preventdefault?

---

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [2019年三月5日 01:58 UTC](https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683/2 "2019-03-05T01:58:39Z")

</div>

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

 ![](https://global.discourse-cdn.com/meta/original/3X/3/e/3e8e903baf98e72300b5837aee24e6d97ee2b5dd.png)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2019年三月5日 05:50 UTC](https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683/3 "2019-03-05T05:50:21Z")

</div>

> [@JustinBack](#):
>
> When SSO is enabled all other login methods disappear, thats why I use a widget to add a GitHub button to the navbar

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.

---

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [2019年三月5日 06:11 UTC](https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683/4 "2019-03-05T06:11:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2019年三月5日 11:06 UTC](https://meta.discourse.org/t/preventing-the-js-to-dynamically-load-the-hyperlink/110683/5 "2019-03-05T11:06:38Z")

</div>


