...
 
Commits (2)
......@@ -39,6 +39,12 @@ class SIBAuth extends HTMLElement {
}, timeout);
}
async trackSession() {
if (this.session) return this.session;
this.session = await new Promise(a => auth.trackSession(a));
return this.session;
}
/** @function
* @name disconnectedCallback
* Clear state and user, uninstall
......@@ -181,15 +187,10 @@ class SIBAuth extends HTMLElement {
* @return {User}
*/
// eslint-disable-next-line class-methods-use-this
getUserWebId() {
return new Promise((resolve) => {
auth.trackSession((session) => {
if (!session) {
return resolve(null);
}
return resolve(session.webId);
});
});
async getUserWebId() {
const session = await this.trackSession();
if (!session) return null;
return session.webId;
}
......@@ -199,15 +200,10 @@ class SIBAuth extends HTMLElement {
* @return {User}
*/
// eslint-disable-next-line class-methods-use-this
getUserIdToken() {
return new Promise((resolve) => {
auth.trackSession((session) => {
if (!session) {
return resolve(null);
}
return resolve(session.authorization && session.authorization.id_token);
});
});
async getUserIdToken() {
const session = await this.trackSession();
if (!session) return null;
return session.authorization && session.authorization.id_token;
}
/** @function
......