Skip to content
Snippets Groups Projects
index.html 1.48 KiB
Newer Older
Clément's avatar
Clément committed
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>SIB-OIDC test</title>
    <script type="module" src="./dist/index.js"></script>
Clément's avatar
Clément committed
    <style>
Clément's avatar
Clément committed
      .bu-test {
Clément's avatar
Clément committed
        border: 3px solid red;
        padding: 0.5rem;
        margin-bottom: 1rem;
Clément's avatar
Clément committed
      }
Clément's avatar
Clément committed
      .bu-test[data-src] {
Clément's avatar
Clément committed
        border-color: green;
      }
Clément's avatar
Clément committed
      .bu-test:after {
        content: "???";
Clément's avatar
Clément committed
      }
Clément's avatar
Clément committed
      .bu-test[data-src]:after {
Clément's avatar
Clément committed
        color: green;
        content: attr(data-src);
      }
Clément's avatar
Clément committed
    </style>
Clément's avatar
Clément committed
  </head>
  <body>
Clément's avatar
Clément committed
    <h1>sib-oidc</h1>
    <div id="result"></div>
    <div bind-user class="bu-test">user-id:</div>
Clément's avatar
Clément committed
      <button id="login">Se connecter</button>
      <button id="logout">Se déconnecter</button>
Matthieu Fesselier's avatar
Matthieu Fesselier committed
    <sib-auth>
      <sib-auth-provider
        data-authority="https://api.test3.startinblox.com"
        data-id="test"
Matthieu Fesselier's avatar
Matthieu Fesselier committed
      ></sib-auth-provider>
    </sib-auth>
Clément's avatar
Clément committed

    <script type="module">
      const sibAuth = document.querySelector("sib-auth")
      login.onclick = () => sibAuth.login()
      logout.onclick = () => sibAuth.logout()

      document.addEventListener("DOMContentLoaded", () => {
        sibAuth.getUser().then(user => {
          result.innerHTML = !user
            ? `Vous n'êtes pas connecté !`
            : `User Web-Id: <pre>${user["@id"]}</pre>`
        });
      })
Clément's avatar
Clément committed
    </script>
Clément's avatar
Clément committed
  </body>
Clément's avatar
Clément committed
</html>