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

Integrate provider for auth in dbp-auth-demo

parent 45e8c03d
No related branches found
No related tags found
No related merge requests found
Pipeline #16441 passed
......@@ -7,7 +7,9 @@
<body>
<dbp-auth-demo lang="de" entry-point-url="http://127.0.0.1:8000"></dbp-auth-demo>
<dbp-provider auth>
<dbp-auth-demo lang="de" entry-point-url="http://127.0.0.1:8000" subscribe="auth:auth"></dbp-auth-demo>
</dbp-provider>
</body>
</html>
......@@ -6,12 +6,14 @@ import {LoginButton} from './login-button.js';
import * as commonUtils from '@dbp-toolkit/common/utils';
import {name as pkgName} from './../package.json';
import DBPLitElement from "@dbp-toolkit/common/dbp-lit-element";
import {Provider} from '@dbp-toolkit/provider';
class AuthDemo extends ScopedElementsMixin(DBPLitElement) {
constructor() {
super();
this.lang = 'de';
this.entryPointUrl = '';
this.auth = {};
}
static get scopedElements() {
......@@ -26,6 +28,7 @@ class AuthDemo extends ScopedElementsMixin(DBPLitElement) {
...super.properties,
lang: { type: String },
entryPointUrl: { type: String, attribute: 'entry-point-url' },
auth: { type: Object },
};
}
......@@ -40,7 +43,7 @@ class AuthDemo extends ScopedElementsMixin(DBPLitElement) {
}
async _onUserInfoClick() {
if (!window.DBPAuthToken) {
if (!this.auth.token) {
console.error("not logged in");
return;
}
......@@ -51,7 +54,7 @@ class AuthDemo extends ScopedElementsMixin(DBPLitElement) {
userInfoURL, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + window.DBPAuthToken
'Authorization': 'Bearer ' + this.auth.token
}
}
);
......@@ -59,12 +62,12 @@ class AuthDemo extends ScopedElementsMixin(DBPLitElement) {
}
async _onShowToken() {
if (!window.DBPAuthToken) {
if (!this.auth.token) {
console.error("not logged in");
return;
}
console.log(window.DBPAuthToken);
console.log(this.auth.token);
}
render() {
......@@ -107,4 +110,5 @@ class AuthDemo extends ScopedElementsMixin(DBPLitElement) {
}
}
commonUtils.defineCustomElement('dbp-provider', Provider);
commonUtils.defineCustomElement('dbp-auth-demo', AuthDemo);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment