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

Remove dbp-auth-person-init event

parent f5a3baf5
No related branches found
No related tags found
No related merge requests found
Pipeline #16245 passed
...@@ -36,10 +36,6 @@ npm i @dbp-toolkit/auth ...@@ -36,10 +36,6 @@ npm i @dbp-toolkit/auth
- `silent-check-sso-redirect-uri` (optional): URI or path to a separate page for checking the login session in an iframe, see https://www.keycloak.org/docs/latest/securing_apps/#_javascript_adapter - `silent-check-sso-redirect-uri` (optional): URI or path to a separate page for checking the login session in an iframe, see https://www.keycloak.org/docs/latest/securing_apps/#_javascript_adapter
- `scope` (optional): Space separated list of scopes to request. These scopes get added in addition to the default ones, assuming the scope is in the optional scopes list of the Keycloak client in use. - `scope` (optional): Space separated list of scopes to request. These scopes get added in addition to the default ones, assuming the scope is in the optional scopes list of the Keycloak client in use.
### Events to listen to
- `dbp-auth-person-init`: Keycloak person init event - the person entity was loaded from the server
## Login Button ## Login Button
### Usage ### Usage
......
...@@ -16,8 +16,7 @@ import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element"; ...@@ -16,8 +16,7 @@ import {AdapterLitElement} from "@dbp-toolkit/provider/src/adapter-lit-element";
* window.DBPAuthTokenParsed: Keycloak token content * window.DBPAuthTokenParsed: Keycloak token content
* window.DBPUserFullName: Full name of the user * window.DBPUserFullName: Full name of the user
* window.DBPPersonId: Person identifier of the user * window.DBPPersonId: Person identifier of the user
* window.DBPPerson: Person json object of the user (optional, enable by setting the `load-person` attribute, * window.DBPPerson: Person json object of the user (optional, enable by setting the `load-person` attribute)
* which will dispatch a `dbp-auth-person-init` event when loaded)
*/ */
export class AuthKeycloak extends AdapterLitElement { export class AuthKeycloak extends AdapterLitElement {
constructor() { constructor() {
...@@ -43,9 +42,6 @@ export class AuthKeycloak extends AdapterLitElement { ...@@ -43,9 +42,6 @@ export class AuthKeycloak extends AdapterLitElement {
this.scope = null; this.scope = null;
this.idpHint = ''; this.idpHint = '';
// Create the events
this.personInitEvent = new CustomEvent("dbp-auth-person-init", { "detail": "KeyCloak person init event", bubbles: true, composed: true });
this._onKCChanged = this._onKCChanged.bind(this); this._onKCChanged = this._onKCChanged.bind(this);
} }
...@@ -127,7 +123,6 @@ export class AuthKeycloak extends AdapterLitElement { ...@@ -127,7 +123,6 @@ export class AuthKeycloak extends AdapterLitElement {
.then((person) => { .then((person) => {
that.person = person; that.person = person;
window.DBPPerson = person; window.DBPPerson = person;
that.dispatchEvent(that.personInitEvent);
this._setLoginStatus(this._loginStatus, true); this._setLoginStatus(this._loginStatus, true);
}); });
}, {}, that.lang); }, {}, that.lang);
......
...@@ -88,7 +88,6 @@ export class LoginButton extends ScopedElementsMixin(LitElement) { ...@@ -88,7 +88,6 @@ export class LoginButton extends ScopedElementsMixin(LitElement) {
this._bus = new EventBus(); this._bus = new EventBus();
this._bus.subscribe('auth-update', (data) => { this._bus.subscribe('auth-update', (data) => {
console.log(data);
this._loginData = data; this._loginData = data;
}); });
} }
......
...@@ -8,6 +8,7 @@ import * as commonUtils from '@dbp-toolkit/common/utils'; ...@@ -8,6 +8,7 @@ import * as commonUtils from '@dbp-toolkit/common/utils';
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
import $ from 'jquery'; import $ from 'jquery';
import {PersonSelect} from '@dbp-toolkit/person-select'; import {PersonSelect} from '@dbp-toolkit/person-select';
import {EventBus} from '@dbp-toolkit/common';
export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
constructor() { constructor() {
...@@ -43,11 +44,14 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -43,11 +44,14 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
i18n.changeLanguage(this.lang); i18n.changeLanguage(this.lang);
const that = this; const that = this;
this.updateComplete.then(()=>{ this._bus = new EventBus();
window.addEventListener("dbp-auth-person-init", () => { this._bus.subscribe('auth-update', (data) => {
that.person = window.DBPPersonId; if (data.person) {
}); this.person = data.person.identifier;
}
});
this.updateComplete.then(()=>{
const personSelect = that._(this.constructor.getScopedTagName('dbp-person-select')); const personSelect = that._(this.constructor.getScopedTagName('dbp-person-select'));
personSelect.onchange = function () { personSelect.onchange = function () {
that.selectedPerson = $(this).data("object").identifier; that.selectedPerson = $(this).data("object").identifier;
...@@ -56,6 +60,11 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -56,6 +60,11 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
}); });
} }
disconnectedCallback() {
this._bus.close();
super.disconnectedCallback();
}
static get styles() { static get styles() {
// language=css // language=css
return css` return css`
......
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