Skip to content
Snippets Groups Projects
Unverified Commit f32534b4 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Integrate auth property into dbp-person-profile

parent 04c7e747
No related branches found
No related tags found
No related merge requests found
Pipeline #16454 passed
...@@ -21,6 +21,8 @@ npm i @dbp-toolkit/person-profile ...@@ -21,6 +21,8 @@ npm i @dbp-toolkit/person-profile
- example `<dbp-person-profile entry-point-url="http://127.0.0.1:8000"></dbp-person-profile>` - example `<dbp-person-profile entry-point-url="http://127.0.0.1:8000"></dbp-person-profile>`
- `value` (optional): api path of person to preload the selector with - `value` (optional): api path of person to preload the selector with
- example `<dbp-person-profile value="/people/testuser"></dbp-person-profile>` - example `<dbp-person-profile value="/people/testuser"></dbp-person-profile>`
- `auth` object: you need to set that object property for the auth token
- example auth property: `{token: "THE_BEARER_TOKEN"}`
## Local development ## Local development
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
<body> <body>
<dbp-person-profile-demo lang="de" entry-point-url="http://127.0.0.1:8000"></dbp-person-profile-demo> <dbp-person-profile-demo auth lang="de" entry-point-url="http://127.0.0.1:8000"></dbp-person-profile-demo>
</body> </body>
</html> </html>
...@@ -97,7 +97,7 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -97,7 +97,7 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
<h1 class="title">Person-Profile-Demo</h1> <h1 class="title">Person-Profile-Demo</h1>
</div> </div>
<div class="container"> <div class="container">
<dbp-person-profile lang="${this.lang}" entry-point-url="${this.entryPointUrl}" value="${this.person}"></dbp-person-profile> <dbp-person-profile subscribe="auth:auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" value="${this.person}"></dbp-person-profile>
</div> </div>
</section> </section>
<section class="section"> <section class="section">
...@@ -105,10 +105,10 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -105,10 +105,10 @@ export class PersonProfileDemo extends ScopedElementsMixin(DBPLitElement) {
<h1 class="title">Select-Profile-Demo</h1> <h1 class="title">Select-Profile-Demo</h1>
</div> </div>
<div class="container"> <div class="container">
<dbp-person-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-person-select> <dbp-person-select subscribe="auth:auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-person-select>
</div> </div>
<div class="container"> <div class="container">
<dbp-person-profile lang="${this.lang}" entry-point-url="${this.entryPointUrl}" value="${this.selectedPerson}"></dbp-person-profile> <dbp-person-profile subscribe="auth:auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" value="${this.selectedPerson}"></dbp-person-profile>
</div> </div>
</section> </section>
`; `;
......
...@@ -15,6 +15,7 @@ export class PersonProfile extends DBPLitElement { ...@@ -15,6 +15,7 @@ export class PersonProfile extends DBPLitElement {
this.jsonld = null; this.jsonld = null;
this.value = ''; this.value = '';
this.person = null; this.person = null;
this.auth = {};
} }
static get properties() { static get properties() {
...@@ -24,6 +25,7 @@ export class PersonProfile extends DBPLitElement { ...@@ -24,6 +25,7 @@ export class PersonProfile extends DBPLitElement {
entryPointUrl: { type: String, attribute: 'entry-point-url' }, entryPointUrl: { type: String, attribute: 'entry-point-url' },
value: { type: String }, value: { type: String },
person: { type: Object, attribute: false }, person: { type: Object, attribute: false },
auth: { type: Object },
}; };
} }
...@@ -56,7 +58,7 @@ export class PersonProfile extends DBPLitElement { ...@@ -56,7 +58,7 @@ export class PersonProfile extends DBPLitElement {
fetch(apiUrl, { fetch(apiUrl, {
headers: { headers: {
'Content-Type': 'application/ld+json', 'Content-Type': 'application/ld+json',
'Authorization': 'Bearer ' + window.DBPAuthToken, 'Authorization': 'Bearer ' + this.auth.token,
}, },
}) })
.then(response => response.json()) .then(response => response.json())
......
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