# Disable social login when an SSO domain is detected

**URL:** <https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909>\
**Category:** Get Help\
**Tags:** social, sso\
**Created:** [March 25, 2020, 11:41am UTC](https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909 "2020-03-25T11:41:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkav](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tkav/32/15515_2.png) [@tkav](https://community.auth0.com/u/tkav)\
**Post date:** [March 25, 2020, 11:41am UTC](https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909/1 "2020-03-25T11:41:41Z")

</div>

We have enabled a social connection (Google) and it works as advertised, it’s great.  
We have also set up some enterprise conections and they also work as advertised, amazing stuff!

However, there is a **weird interaction between those two** :  
When a user enters their email and it belongs to one of the enterprise connection domains, the password field disappears (since they’re using SSO and no password is necessary). **BUT the social login does not disappear** (unlike the password field), which causes confusion to some users. Is there a built-in way to work around this issue?  
We’d like to keep using non-customized Classic Unified Login as customizing it would mean that we’d have to maintain it ourselves.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![mathiasconradt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mathiasconradt/32/12758_2.png) [@mathiasconradt](https://community.auth0.com/u/mathiasconradt)\
**Post date:** [March 25, 2020, 11:55am UTC](https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909/2 "2020-03-25T11:55:59Z")

</div>

If you’re using the Classic ULP, you can customize the login page, and it should be possible with common javascript event listeners, that listen to the the event that shows/hides the password field.  
So, nothing out of the box, but possible with little custom js scripting.

---

<div class="post-metadata">

**Author:** ![tkav](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tkav/32/15515_2.png) [@tkav](https://community.auth0.com/u/tkav)\
**Post date:** [March 26, 2020, 8:26am UTC](https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909/3 "2020-03-26T08:26:01Z")

</div>

The code we came up with is as follows:

```auto
// This removes social login if SSO domain is detected
    function callback(mutationsList) {
      mutationsList.forEach(mutation => {
          mutation.removedNodes.forEach(removedNode => {
              if (removedNode.className.includes("auth0-lock-tabs-container")) {
                  document.getElementsByClassName("auth-lock-social-buttons-pane")[0].style.display = "none";
                  document.getElementsByClassName("auth0-lock-pane-separator")[0].nextSibling.children[0].style.display = "none";
              }
          })
          mutation.addedNodes.forEach(addedNode => {
              if (addedNode.className.includes("auth0-lock-tabs-container")) {
                  document.getElementsByClassName("auth-lock-social-buttons-pane")[0].style.display = "block";
                  document.getElementsByClassName("auth0-lock-pane-separator")[0].nextSibling.children[0].style.display = "block";
              }
          })
      })
    }
    const mutationObserver = new MutationObserver(callback);
    lock.on("show", () => {
      setTimeout(() => {
        // If email is prefilled with SSO domain, the observer added below would not work for the first time
        if (!document.getElementsByClassName("auth0-lock-tabs-container").length){
          document.getElementsByClassName("auth-lock-social-buttons-pane")[0].style.display = "none";
          document.getElementsByClassName("auth0-lock-pane-separator")[0].nextSibling.children[0].style.display = "none";
        }
        let authLockForm = document.getElementsByClassName("auth0-lock-form");
        authLockForm = authLockForm && authLockForm[0];
        if (authLockForm) {
          mutationObserver.observe(authLockForm, {childList: true, subtree: true});
        } else {
          console.log("DOM didn't load in time");
        }
      }, 1000);
    });

```

Add this after `lock.show()`.

The reason for the timeout is that even though `show` has fired, the element we look for is not guaranteed to be present.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 26, 2020, 8:40am UTC](https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909/4 "2020-03-26T08:40:33Z")

</div>

Thanks for sharing that @tkav!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 10, 2020, 8:40am UTC](https://community.auth0.com/t/disable-social-login-when-an-sso-domain-is-detected/39909/5 "2020-04-10T08:40:38Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
