Skip to content
Snippets Groups Projects
Commit 7e82a4ad authored by Benoit Alessandroni's avatar Benoit Alessandroni
Browse files

Fix user from store retrieval

parent 36f09f07
No related branches found
No related tags found
1 merge request!137Fix router bug
Pipeline #5025 failed
...@@ -13,9 +13,6 @@ section#home ...@@ -13,9 +13,6 @@ section#home
// and grouped by steps // and grouped by steps
// From two different endpoints I guess // From two different endpoints I guess
//-Work on the page architecture //-Work on the page architecture
//TODO : investigate why we have to remove hidden attribute to see this even if we are on the right route.
#entrepreneur-resource-list(hidden).no-sidebar.container #entrepreneur-resource-list(hidden).no-sidebar.container
include ./resources/list.pug include ./resources/list.pug
......
...@@ -2,6 +2,7 @@ head ...@@ -2,6 +2,7 @@ head
title CoopStarter title CoopStarter
meta(charset="utf-8") meta(charset="utf-8")
script(src="https://unpkg.com/@webcomponents/webcomponentsjs@1.2.7/webcomponents-loader.js") script(src="https://unpkg.com/@webcomponents/webcomponentsjs@1.2.7/webcomponents-loader.js")
//- script(type="module" src="/scripts/sib-core/dist/index.js")
script(type="module" src="https://unpkg.com/@startinblox/core@0.9") script(type="module" src="https://unpkg.com/@startinblox/core@0.9")
script(type="module" src="https://unpkg.com/@startinblox/router@0.7") script(type="module" src="https://unpkg.com/@startinblox/router@0.7")
script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8.4") script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8.4")
......
...@@ -29,13 +29,13 @@ html ...@@ -29,13 +29,13 @@ html
#main-loader(hidden style="display: none") Loading… #main-loader(hidden style="display: none") Loading…
sib-auth sib-auth
sib-auth-provider( sib-auth-provider(
class="sib-auth-provider" class="sib-auth-provider"
data-authority=`${sdn}` data-authority=`${sdn}`
data-id="coopstarter" data-id="coopstarter"
) )
script(type='module' src='/scripts/dispatch-space-n-user.js') script(type='module' src='/scripts/dispatch-space-n-user.js')
import { store, base_context } from 'https://unpkg.com/@startinblox/core@0.9/dist/libs/store/store.js'; import { store } from 'https://unpkg.com/@startinblox/core@0.9';
const sibAuth = document.querySelector('sib-auth'); const sibAuth = document.querySelector('sib-auth');
const context = {
'@vocab': 'http://happy-dev.fr/owl/#',
rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
ldp: 'http://www.w3.org/ns/ldp#',
foaf: 'http://xmlns.com/foaf/0.1/',
name: 'rdfs:label',
acl: 'http://www.w3.org/ns/auth/acl#',
permissions: 'acl:accessControl',
mode: 'acl:mode',
geo: "http://www.w3.org/2003/01/geo/wgs84_pos#",
lat: "geo:lat",
lng: "geo:long",
'mentor_profile': 'http://happy-dev.fr/owl/#mentor_profile',
'entrepreneur_profile': 'http://happy-dev.fr/owl/#entrepreneur_profile',
};
//We create a custom element //We create a custom element
class CoopStarterLoginComponent extends HTMLElement { class CoopStarterLoginComponent extends HTMLElement {
...@@ -35,24 +52,23 @@ class CoopStarterLoginComponent extends HTMLElement { ...@@ -35,24 +52,23 @@ class CoopStarterLoginComponent extends HTMLElement {
loader.removeAttribute('hidden'); loader.removeAttribute('hidden');
let user = await sibAuth.getUser(); let user = await sibAuth.getUser();
console.log(user);
//Set a userprefix default status //Set a userprefix default status
var userPrefix = "public" var userPrefix = "public"
// Idenfify the space we should go // Idenfify the space we should go
if (user) { if (user) {
await store.initGraph(user['@id'], base_context); await store.initGraph(user['@id'], context);
user = await store.get(user['@id']); let userFromStore = await store.get(user['@id']);
// if (!user)
// user = await store.get(user);
console.log(user);
//If the user is a mentor or an entreprenur, change user prefix //If the user is a mentor or an entreprenur, change user prefix
if(user && await user.mentor_profile) { if(user) {
console.log(user); let is_mentor = await userFromStore.mentor_profile;
let is_entrepreneur = await userFromStore.entrepreneur_profile;
if (is_mentor) {
userPrefix = "mentor" userPrefix = "mentor"
} else if (user && await user.entrepreneur_profile) { } else if(is_entrepreneur) {
userPrefix = "entrepreneur" userPrefix = "entrepreneur"
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment