From 2be340a1db0016e25adc8d29a9346c8cd370e527 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Mon, 2 Dec 2019 12:03:33 +0100
Subject: [PATCH] Only emit a changed event in case the token has actually
 changed

Every change to person etc should also mean a new token, so we can reduce
duplicated events by checking if the token has changed.
---
 packages/auth/src/vpu-auth.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/packages/auth/src/vpu-auth.js b/packages/auth/src/vpu-auth.js
index 4aa0cdd6..aa1e549a 100644
--- a/packages/auth/src/vpu-auth.js
+++ b/packages/auth/src/vpu-auth.js
@@ -73,6 +73,7 @@ class VPUAuth extends VPULitElement {
         let newPerson = false;
 
         if (kc.authenticated) {
+            let tokenChanged = (this.token !== kc.token);
             this.name = kc.idTokenParsed.name;
             this.token = kc.token;
             this.subject = kc.subject;
@@ -82,7 +83,7 @@ class VPUAuth extends VPULitElement {
                 newPerson = true;
             }
             this.personId = personId;
-            this._setLoginStatus(LoginStatus.LOGGED_IN, true);
+            this._setLoginStatus(LoginStatus.LOGGED_IN, tokenChanged);
         } else {
             this.name = "";
             this.token = "";
-- 
GitLab