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

fix: somes bugs

parent 48ea2c21
...@@ -69,8 +69,8 @@ ...@@ -69,8 +69,8 @@
return this.getUser(); return this.getUser();
} }
update() { async update() {
const user = this.getUser(); const user = await this.getUser();
if (user) { if (user) {
result.innerHTML = `Bonjour ${user} !`; result.innerHTML = `Bonjour ${user} !`;
} else { } else {
...@@ -81,4 +81,4 @@ ...@@ -81,4 +81,4 @@
customElements.define('sib-test', TestComponent); customElements.define('sib-test', TestComponent);
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
import auth from 'https://dev.jspm.io/solid-auth-client'; 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 { class SIBAuthProvider extends HTMLElement {
/** /**
* @typedef {Object} State * @typedef {Object} State
...@@ -25,12 +14,21 @@ class SIBAuthProvider extends HTMLElement { ...@@ -25,12 +14,21 @@ class SIBAuthProvider extends HTMLElement {
} }
/** @function /** @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 * @name disconnectedCallback
* Remove manager * Remove manager
*/ */
disconnectedCallback() { disconnectedCallback() {
this.manager = null;
} }
/** @function /** @function
......
import auth from 'https://dev.jspm.io/solid-auth-client'; 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(/\/[^/]*$/, ''); const baseUrl = import.meta.url.replace(/\/[^/]*$/, '');
Helpers.importCSS(`${baseUrl}/sib-auth.css`); Helpers.importCSS(`${baseUrl}/sib-auth.css`);
...@@ -15,7 +15,7 @@ class SIBAuth extends HTMLElement { ...@@ -15,7 +15,7 @@ class SIBAuth extends HTMLElement {
constructor() { constructor() {
super(); super();
this.state = null; this.provider = null;
this.user = null; this.user = null;
this.hide(); this.hide();
} }
...@@ -40,7 +40,6 @@ class SIBAuth extends HTMLElement { ...@@ -40,7 +40,6 @@ class SIBAuth extends HTMLElement {
disconnectedCallback() { disconnectedCallback() {
solid.auth.logout() solid.auth.logout()
.then(() => alert('Goodbye!')); .then(() => alert('Goodbye!'));
this.clearState();
this.uninstall(); this.uninstall();
} }
...@@ -140,7 +139,7 @@ class SIBAuth extends HTMLElement { ...@@ -140,7 +139,7 @@ class SIBAuth extends HTMLElement {
* Try to get user, the if a state is set, call the appropriate provider * Try to get user, the if a state is set, call the appropriate provider
*/ */
async processState() { async processState() {
const { provider } = this.getState(); const {provider} = this.getState();
const providerElement = this.getProvider(provider); const providerElement = this.getProvider(provider);
if (providerElement) { if (providerElement) {
this.callProvider(providerElement, 'processState', this); this.callProvider(providerElement, 'processState', this);
...@@ -189,7 +188,7 @@ class SIBAuth extends HTMLElement { ...@@ -189,7 +188,7 @@ class SIBAuth extends HTMLElement {
* Return User or undefined * Return User or undefined
* @return {User} * @return {User}
*/ */
getUserWebId() { getUserWebId() {
return new Promise((resolve, error) => { return new Promise((resolve, error) => {
auth.trackSession(session => { auth.trackSession(session => {
if (!session) { if (!session) {
...@@ -219,11 +218,8 @@ class SIBAuth extends HTMLElement { ...@@ -219,11 +218,8 @@ class SIBAuth extends HTMLElement {
* @name logout * @name logout
* Try to logout if favorite provider is set * Try to logout if favorite provider is set
*/ */
async logout() { logout() {
const favoriteProvider = this.getFavoriteProvider(); auth.logout()
if (favoriteProvider) {
this.callProvider(favoriteProvider, 'logout', this);
}
} }
/** @function /** @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