Newer
Older
doctype html
html
include includes/head.pug
sib-router(default-route='splash')
sib-route(name='splash')
sib-route(name='mentor-dashboard')
sib-route(name='entrepreneur-dashboard')
include includes/mentor/dashboard.pug
include includes/entrepreneur/dashboard.pug
#account-creation(hidden).no-sidebar.container
include includes/account-creation.pug
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() {
await sibAuth.login();
}
async update() {
let user = await sibAuth.getUser();
let idToken = await sibAuth.getUserIdToken();
if ( !user ) {
return;
}
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);