From aa975d5e69446f4a4ef080ef903b6eedb6603b69 Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio@bekerle.com>
Date: Thu, 14 Jan 2021 15:46:07 +0100
Subject: [PATCH] Send set-property events in auth component
 (dbp/apps/signature#32)

---
 packages/auth/src/auth-keycloak.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/packages/auth/src/auth-keycloak.js b/packages/auth/src/auth-keycloak.js
index f57c681d..840c611e 100644
--- a/packages/auth/src/auth-keycloak.js
+++ b/packages/auth/src/auth-keycloak.js
@@ -87,6 +87,7 @@ export class AuthKeycloak extends AdapterLitElement {
             window.DBPPersonId = this.personId;
             window.DBPPerson = this.person;
 
+            this.sendSetPropertyEvents();
             this._setLoginStatus(LoginStatus.LOGGED_IN, tokenChanged || newPerson);
         } else {
             if (this._loginStatus === LoginStatus.LOGGED_IN) {
@@ -106,6 +107,7 @@ export class AuthKeycloak extends AdapterLitElement {
             window.DBPPersonId = this.personId;
             window.DBPPerson = this.person;
 
+            this.sendSetPropertyEvents();
             this._setLoginStatus(LoginStatus.LOGGED_OUT);
         }
 
@@ -141,6 +143,15 @@ export class AuthKeycloak extends AdapterLitElement {
         this.dispatchEvent(this.keycloakDataUpdateEvent);
     }
 
+    sendSetPropertyEvents() {
+        this.sendSetPropertyEvent('auth-subject', this.subject);
+        this.sendSetPropertyEvent('auth-token', this.token);
+        this.sendSetPropertyEvent('auth-token-parsed', this.tokenParsed);
+        this.sendSetPropertyEvent('user-full-name', this.name);
+        this.sendSetPropertyEvent('person-id', this.personId);
+        this.sendSetPropertyEvent('person', this.person);
+    }
+
     _setLoginStatus(status, force) {
         if (this._loginStatus === status && !force)
             return;
-- 
GitLab