Commit 31b2fb90 authored by Jean-Baptiste's avatar Jean-Baptiste Committed by Clément

fix: somes bugs

parent 48ea2c21
......@@ -69,8 +69,8 @@
return this.getUser();
}
update() {
const user = this.getUser();
async update() {
const user = await this.getUser();
if (user) {
result.innerHTML = `Bonjour ${user} !`;
} else {
......@@ -81,4 +81,4 @@
customElements.define('sib-test', TestComponent);
</script>
</body>
</html>
</html>
\ No newline at end of file
import auth from 'https://dev.jspm.io/solid-auth-client';
const defaultSettings = {
redirect_uri: window.location.origin,
post_logout_redirect_uri: window.location.origin,
// authority: 'https://test-paris.happy-dev.fr/openid/',
// client_id: '833925',
response_type: 'id_token token',
scope: 'openid profile email',
automaticsilentrenew: 'true',
loaduserinfo: 'true',
};
class SIBAuthProvider extends HTMLElement {
/**
* @typedef {Object} State
......@@ -25,12 +14,21 @@ class SIBAuthProvider extends HTMLElement {
}
/** @function
*
* @name connectedCallback
* When called, the OIDC manager is intancied
* with the params set in the component, render view
*/
async connectedCallback() {
const { authority, id } = this.dataset; // eslint-disable-line camelcase
this.id = id;
this.render(this.dataset);
}
/** @function
* @name disconnectedCallback
* Remove manager
*/
disconnectedCallback() {
this.manager = null;
}
/** @function
......
import auth from 'https://dev.jspm.io/solid-auth-client';
import { SIBBase, Helpers } from 'https://unpkg.com/@startinblox/core@0.7';
import {Helpers, SIBBase} from 'https://unpkg.com/@startinblox/core@0.7';
const baseUrl = import.meta.url.replace(/\/[^/]*$/, '');
Helpers.importCSS(`${baseUrl}/sib-auth.css`);
......@@ -15,7 +15,7 @@ class SIBAuth extends HTMLElement {
constructor() {
super();
this.state = null;
this.provider = null;
this.user = null;
this.hide();
}
......@@ -40,7 +40,6 @@ class SIBAuth extends HTMLElement {
disconnectedCallback() {
solid.auth.logout()
.then(() => alert('Goodbye!'));
this.clearState();
this.uninstall();
}
......@@ -140,7 +139,7 @@ class SIBAuth extends HTMLElement {
* Try to get user, the if a state is set, call the appropriate provider
*/
async processState() {
const { provider } = this.getState();
const {provider} = this.getState();
const providerElement = this.getProvider(provider);
if (providerElement) {
this.callProvider(providerElement, 'processState', this);
......@@ -189,7 +188,7 @@ class SIBAuth extends HTMLElement {
* Return User or undefined
* @return {User}
*/
getUserWebId() {
getUserWebId() {
return new Promise((resolve, error) => {
auth.trackSession(session => {
if (!session) {
......@@ -219,11 +218,8 @@ class SIBAuth extends HTMLElement {
* @name logout
* Try to logout if favorite provider is set
*/
async logout() {
const favoriteProvider = this.getFavoriteProvider();
if (favoriteProvider) {
this.callProvider(favoriteProvider, 'logout', this);
}
logout() {
auth.logout()
}
/** @function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment