Newer
Older
doctype html
html
include includes/head.pug
sib-router(default-route='splash' route-prefix=lang)
sib-route(name='mentor-dashboard')
sib-route(name='entrepreneur-dashboard')
sib-route(name='public-dashboard')
include includes/components/widgets.pug
include includes/mentor/dashboard.pug
include includes/entrepreneur/dashboard.pug
#account-creation(hidden).no-sidebar.container
include includes/account-creation.pug
#public-dashboard(hidden).no-sidebar
include includes/public/dashboard.pug
#main-loader(hidden) Loading…
sib-auth
sib-auth-provider(
class="sib-auth-provider"
data-authority=`${sdn}`
data-id="coopstarter"
)
script(type='module').
import { store } from 'https://unpkg.com/@startinblox/core@0.8';
const sibAuth = document.querySelector('sib-auth');
class CoopStarterLoginComponent extends HTMLElement {
async connectedCallback() {
mentor_login.onclick = () => this.triggerLogin();
this.update();
}
async triggerLogin() {
let loader = document.getElementById('main-loader');
loader.removeAttribute('hidden');
await sibAuth.login();
}
async update() {
let loader = document.getElementById('main-loader');
loader.removeAttribute('hidden');
let user = await sibAuth.getUser();
let idToken = await sibAuth.getUserIdToken();
console.log(window.location);
if ( !user && window.location.href.indexOf('public-dashboard/public-resource-detail') === -1) {
console.log("We have no user and not in public")
loader.setAttribute("hidden", true);
window.dispatchEvent(
new CustomEvent('requestNavigation', { detail: { route: 'splash' } })
);
if(!user && window.location.href.indexOf('public-dashboard/public-resource-detail') > -1) {
console.log("We are targetting the public space !")
//- window.dispatchEvent(
//- new CustomEvent('requestNavigation', { detail: {
//- route: 'public-resource-detail'
//- } })
//- );
loader.setAttribute("hidden", true);
}
user = await store.get(user);
if (user && user.mentor_profile) {
window.dispatchEvent(
new CustomEvent('requestNavigation', { detail: { route: 'mentor-dashboard' } })
);
} else if (user && user.entrepreneur_profile) {
window.dispatchEvent(
new CustomEvent('requestNavigation', { detail: { route: 'entrepreneur-dashboard' } })
);
} else {
window.dispatchEvent(
new CustomEvent('requestNavigation', { detail: { route: 'account-creation' } })
);
}
}
empty(){}
populate(){}
}
customElements.define('cs-login', CoopStarterLoginComponent);