Skip to content
Snippets Groups Projects
Commit 15ba49ad authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Add vpu-auth-keycloak-data-update event

parent 6ee9d4c2
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,10 @@
- `force-login` (optional, default: off): if enabled a login will be forced, there never will be a login button
- example `<vpu-auth client-id="my-dev-client-id" force-login></vpu-auth>`
## Events
TODO
## Local development
```bash
......
......@@ -29,9 +29,10 @@ class VPUAuth extends LitElement {
this.name = "";
this.personId = "";
// Create the init event
// Create the events
this.initEvent = new CustomEvent("vpu-auth-init", { "detail": "KeyCloak init event" });
this.personInitEvent = new CustomEvent("vpu-auth-person-init", { "detail": "KeyCloak person init event" });
this.keycloakDataUpdateEvent = new CustomEvent("vpu-auth-keycloak-data-update", { "detail": "KeyCloak data was updated" });
}
/**
......@@ -160,6 +161,7 @@ class VPUAuth extends LitElement {
this.shadowRoot.querySelector('#login-block').style.display = state ? "flex" : "none";
this.shadowRoot.querySelector('#logout-block').style.display = state ? "none" : "flex";
}
/**
* Dispatches the person init event
*/
......@@ -167,6 +169,13 @@ class VPUAuth extends LitElement {
document.dispatchEvent(this.personInitEvent);
}
/**
* Dispatches the keycloak data update event
*/
dispatchKeycloakDataUpdateEvent() {
document.dispatchEvent(this.keycloakDataUpdateEvent);
}
updateKeycloakData() {
this.name = this._keycloak.idTokenParsed.name;
this.token = this._keycloak.token;
......@@ -179,6 +188,7 @@ class VPUAuth extends LitElement {
window.VPUPersonId = this.personId;
console.log("Bearer " + this.token);
this.dispatchKeycloakDataUpdateEvent();
}
render() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment