Skip to content
Snippets Groups Projects
Commit 6ed63f94 authored by Mathieu Massaviol's avatar Mathieu Massaviol
Browse files

Fix problem #57

parent 55879629
No related branches found
No related tags found
1 merge request!61Resolve "Probleme de récupéraction des informations de l'utilisateur à la connection (infos, profil, memberships)"
Pipeline #10647 passed
......@@ -15,7 +15,7 @@ export async function getProfileInfos(auth: Credentials) {
}
profileInfos.infos = memberInfosList[0]
const memberProfileList = await getMemberProfile(profileInfos.infos.hasPrivateGraph, auth)
const memberProfileList = await getMemberProfile(auth)
if (memberProfileList.length === 0) {
console.warn('No profile found for current user.')
// This should not happen but could, due to existing broken data.
......@@ -28,7 +28,7 @@ export async function getProfileInfos(auth: Credentials) {
profileInfos.profile = memberProfileList[0]
}
profileInfos.memberships = await getMemberMemberships(profileInfos.infos.hasSystemGraph, profileInfos.profile["@id"], auth)
profileInfos.memberships = await getMemberMemberships(auth)
return profileInfos
}
......
......@@ -10,12 +10,12 @@ export const getMemberInfos = async (auth: Credentials) => {
CONSTRUCT {
?member oct:hasSystemGraph ?systemGraph;
oct:hasPrivateGraph ?privateGraph;
oct:loginID ?loginId.
oct:loginID ?loginID.
}
WHERE {
?member oct:hasSystemGraph ?systemGraph;
oct:hasPrivateGraph ?privateGraph;
oct:loginID ?loginId.
oct:loginID "${auth.email}".
}
`,
{
......@@ -27,14 +27,13 @@ export const getMemberInfos = async (auth: Credentials) => {
/**
* For a member, i.e. a connected user, get their profile.
*/
export const getMemberProfile = async (memberPrivateGraph: string, auth: Credentials) => {
export const getMemberProfile = async (auth: Credentials) => {
return await executeSparqlConstruct<OcPerson>(
`
CONSTRUCT { ?member ?p ?o. }
FROM<${memberPrivateGraph}>
WHERE {
?member a foaf:Person;
?p ?o.
?member oct:loginID "${auth.email}";
?p ?o.
}
`,
{
......@@ -46,13 +45,13 @@ export const getMemberProfile = async (memberPrivateGraph: string, auth: Credent
/**
* For a member, i.e. a connected user, get the liste of his memberships to communities
*/
export const getMemberMemberships = async (memberSystemGraph: string, memberUri: string, auth: Credentials) => {
export const getMemberMemberships = async (auth: Credentials) => {
return await executeSparqlConstruct<OcMembership>(
`
WITH <${memberSystemGraph}>
CONSTRUCT {?membership ?p2 ?o2.}
WHERE {
<${memberUri}> org:hasMembership ?membership.
?member oct:loginID "${auth.email}";
org:hasMembership ?membership.
?membership ?p2 ?o2
}
`,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment