From 1997616c4d912e05f2af6c8159f84a40d35e7ae0 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Wed, 18 Dec 2019 12:48:13 +0100 Subject: [PATCH] Set the global variables before we emit the status updates and emit after the person is loaded. So we can use the update event to wait for the global variables in other components. Also don't log the status when we get a request as with mulitple users we spam the logs. Moved to the app receiving the events instead. --- packages/auth/src/vpu-auth.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/auth/src/vpu-auth.js b/packages/auth/src/vpu-auth.js index 83c8ce25..38547b0d 100644 --- a/packages/auth/src/vpu-auth.js +++ b/packages/auth/src/vpu-auth.js @@ -51,7 +51,6 @@ class VPUAuth extends VPULitElement { status: this._loginStatus, token: this.token, }; - console.log('Login status: ' + this._loginStatus); return message; }; @@ -84,6 +83,13 @@ class VPUAuth extends VPULitElement { newPerson = true; } this.personId = personId; + + window.VPUAuthSubject = this.subject; + window.VPUAuthToken = this.token; + window.VPUUserFullName = this.name; + window.VPUPersonId = this.personId; + window.VPUPerson = this.person; + this._setLoginStatus(LoginStatus.LOGGED_IN, tokenChanged); } else { if (this._loginStatus === LoginStatus.LOGGED_IN) { @@ -94,15 +100,16 @@ class VPUAuth extends VPULitElement { this.subject = ""; this.personId = ""; this.person = null; + + window.VPUAuthSubject = this.subject; + window.VPUAuthToken = this.token; + window.VPUUserFullName = this.name; + window.VPUPersonId = this.personId; + window.VPUPerson = this.person; + this._setLoginStatus(LoginStatus.LOGGED_OUT); } - window.VPUAuthSubject = this.subject; - window.VPUAuthToken = this.token; - window.VPUUserFullName = this.name; - window.VPUPersonId = this.personId; - window.VPUPerson = this.person; - const that = this; if (newPerson) { @@ -127,6 +134,7 @@ class VPUAuth extends VPULitElement { that.person = person; window.VPUPerson = person; that.dispatchEvent(that.personInitEvent); + this._setLoginStatus(this._loginStatus, true); }); }, {}, that.lang); } -- GitLab