Commit 0b8ca1f0 authored by Nicolas Mérigot's avatar Nicolas Mérigot

feature: update example

parent 17e24cb0
Pipeline #2131 passed with stage
in 27 seconds
......@@ -5,13 +5,25 @@
<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="./sib-oidc.js"></script>
<script type="module" src="./index.js"></script>
</head>
<body>
<sib-auth
<sib-auth class="sib-auth">
<sib-auth-provider
class="sib-auth-provider"
data-authority="https://test-paris.happy-dev.fr/openid/"
data-client_id="833925"
></sib-auth>
data-id="paris"
>
</sib-auth-provider>
<sib-auth-provider
class="sib-auth-provider"
data-authority="https://test-paris.happy-dev.fr/openid/"
data-client_id="833925"
data-id="paris2"
>
</sib-auth-provider>
</sib-auth>
<h1>sib-oidc</h1>
<button id="reset">clear storage and set new URL</button>
<button id="reload">reload</button>
......@@ -29,13 +41,43 @@
class TestComponent extends SIBBase {
async connectedCallback() {
const user = await this.getUser();
this.innerHTML = JSON.stringify(user);
stat.onclick = () => this.getStatus();
login.onclick = () => this.triggerLogin();
logout.onclick = () => this.triggerLogout();
this.update();
}
async triggerLogin() {
await this.login();
}
async triggerLogout() {
await this.logout();
}
async getStatus() {
return this.getUser();
}
update() {
const user = this.getUser();
if (user) {
result.innerHTML = `Bonjour ${user.profile.name} !`;
} else {
result.innerHTML = `Vous n'êtes pas connecté !`;
}
}
}
customElements.define('sib-test', TestComponent);
</script>
<sib-test></sib-test>
<sib-test>
<div id="result">
</div>
<button id="login">Se connecter</button>
<button id="logout">Se déconnecter</button>
<button id="stat">Status</button>
</sib-test>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment