summaryrefslogtreecommitdiff
path: root/inject/disable-password-login.js
blob: fd66b74f9028e3546f17b5eb8ac4d6a5c5a29bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export function disablePasswordLogin() {
  const queryString = new URLSearchParams(window.location.search);
  if (queryString.get("pwauth") == null) {
    document.addEventListener("DOMContentLoaded", function () {
      const sso = document.querySelector(".o_auth_oauth_providers");
      if (sso) {
        const link = sso.getElementsByTagName("a")[0];
        if (link.innerText.search("Authentik") + link.innerText.search("TONI SSO") > 0) {
          console.info("Redirecting to SSO login:", link.href);
          window.location.replace(link.href);
        }
      }
    });
  }
  else {
    console.info("Not skipping password auth due to query string");
  }
}