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