Skip to content
Snippets Groups Projects
Commit 9326dfa5 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Send a logging-out event when transitioning from logged-in to logged-out

This can happen when the session expires, for example if the user has logged
out in another window.

This is useful whenn you want to use "logging-out" to clear user related data.
parent 2be340a1
No related branches found
No related tags found
No related merge requests found
...@@ -85,6 +85,9 @@ class VPUAuth extends VPULitElement { ...@@ -85,6 +85,9 @@ class VPUAuth extends VPULitElement {
this.personId = personId; this.personId = personId;
this._setLoginStatus(LoginStatus.LOGGED_IN, tokenChanged); this._setLoginStatus(LoginStatus.LOGGED_IN, tokenChanged);
} else { } else {
if (this._loginStatus === LoginStatus.LOGGED_IN) {
this._setLoginStatus(LoginStatus.LOGGING_OUT);
}
this.name = ""; this.name = "";
this.token = ""; this.token = "";
this.subject = ""; this.subject = "";
...@@ -217,7 +220,11 @@ class VPUAuth extends VPULitElement { ...@@ -217,7 +220,11 @@ class VPUAuth extends VPULitElement {
} }
onLogoutClicked(e) { onLogoutClicked(e) {
this._setLoginStatus(LoginStatus.LOGGING_OUT); // Keycloak will redirect right away without emitting events, so we have
// to do this manually here
if (this._loginStatus === LoginStatus.LOGGED_IN) {
this._setLoginStatus(LoginStatus.LOGGING_OUT);
}
this._kcwrapper.logout(); this._kcwrapper.logout();
} }
......
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