diff --git a/src/graphql/connectors/authentifiers.js b/src/graphql/connectors/authentifiers.js index 3896f8551fc380e88232e11740e7550d6155dfdb..79f950f17e3e13f09936f8bd4540138f718773dd 100644 --- a/src/graphql/connectors/authentifiers.js +++ b/src/graphql/connectors/authentifiers.js @@ -11,7 +11,7 @@ import { UtilisateurAnonyme, UtilisateurConnecte, AdministrateurConnecte, SuperAdministrateurConnecte } from '../../ldap/ldap_data'; -function user_object(user, ldap_access){ +function User(user, ldap_access){ this.anonymous = Boolean(user.anonymous), this.uid = user.uid, this.password = user.password, @@ -25,7 +25,7 @@ function user_object(user, ldap_access){ * @rights user */ export function anonymous(user){ - return new user_object(user, new UtilisateurAnonyme()); + return new User(user, new UtilisateurAnonyme()); } /** @@ -35,7 +35,7 @@ export function anonymous(user){ * @rights user */ export function loggedIn(user, groupUID){ - return new user_object(user, new UtilisateurConnecte(user)); + return new User(user, new UtilisateurConnecte(user)); } /** @@ -58,7 +58,7 @@ export async function member(user, groupUID){ let group_list = await selectors.groupsWithMember(user); let test = await knex.with('group_list', group_list).select().from('group_list').where('uid', groupUID); if(test[0]) - return new user_object(user, new UtilisateurConnecte(user)); + return new User(user, new UtilisateurConnecte(user)); return await admin(user, groupUID); } diff --git a/src/graphql/connectors/connectors.js b/src/graphql/connectors/connectors.js index 73d21788bca4444624996e72e06b13d2f0eeb29b..836afcb5032b6464ac51c3fc8816973d6e0f3305 100644 --- a/src/graphql/connectors/connectors.js +++ b/src/graphql/connectors/connectors.js @@ -314,13 +314,12 @@ export async function getYourGroupHostEventRequests(user, recipientUID){ //Don't forget the argument user is the guy who makes the request, not the user we want -export const getUser = (user, userUID) => { +export const getUser = (user, uid) => { const refactorer = (data) => { - console.log("type of nick",typeof data.nickname); if (typeof data.brRoom == 'string') data.brRoom = [data.brRoom]; return { - uid: userUID, + uid: uid, lastName: data.sn, givenName: data.givenName, nickname: data.displayName, @@ -334,8 +333,7 @@ export const getUser = (user, userUID) => { }; }; - const result = utilisateur.getUser(user, userUID).then(res => { - console.log(res[0]); + const result = utilisateur.getUser(uid).then(res => { return refactorer(res[0]); }); diff --git a/src/graphql/resolvers.js b/src/graphql/resolvers.js index fd021642ea4baec8e389832a332abcabf7f8bf25..449504c803ea2bfc60195290f67c74bb5da102e2 100644 --- a/src/graphql/resolvers.js +++ b/src/graphql/resolvers.js @@ -9,7 +9,7 @@ import knex from '../../db/knex_router'; import * as connectors from './connectors/connectors'; import * as list_selectors from './connectors/list_selectors'; -import * as authenthifiers from './connectors/authentifiers'; +import * as authentifiers from './connectors/authentifiers'; /** * @description Résolveurs des différentes requêtes GraphQL @@ -21,26 +21,26 @@ export const resolvers = { // group queries allGroups: async function(obj, args, context){ - let user = await authenthifiers.anonymous(context.user); + let user = await authentifiers.anonymous(context.user); return user && connectors.getAllVisibleGroups(user); }, allSimpleGroups: async function (obj, args, context){ - let user = await authenthifiers.anonymous(context.user); + let user = await authentifiers.anonymous(context.user); return user && connectors.getAllVisibleSimpleGroups(user); }, group: async function(obj, args, context){ - let user = await authenthifiers.anonymous(context.user); + let user = await authentifiers.anonymous(context.user); return user && connectors.getGroupIfVisible(user, args.uid); }, simpleGroup: async function(obj, args, context){ - let user = await authenthifiers.anonymous(context.user); + let user = await authentifiers.anonymous(context.user); return user && connectors.getSimpleGroupIfVisible(user, args.uid); }, metaGroup: async function(obj, args, context){ - let user = await authenthifiers.anonymous(context.user); + let user = await authentifiers.anonymous(context.user); return user && connectors.getMetaGroupIfVisible(user, args.uid); }, @@ -50,7 +50,8 @@ export const resolvers = { // user queries user: async function(obj, args, context){ - let user = await authenthifiers.anonymous(context.user); + let user = await authentifiers.anonymous(context.user); + console.log(user); return user && connectors.getUser(user,args.uid); }, @@ -78,7 +79,7 @@ export const resolvers = { // member queries allMembers : async function(obj, args, context){ - let user = await authenthifiers.member(context.user, args.from); + let user = await authentifiers.member(context.user, args.from); return user && connectors.getGroupMemberUsers(context.user, obj.groupUID); }, @@ -86,11 +87,11 @@ export const resolvers = { allRequests: async function(obj, args, context){ let res = []; - let user = authenthifiers.admin(context.user, args.from); + let user = authentifiers.admin(context.user, args.from); if(user){ res = res.concat(await connectors.getUserJoinGroupRequests(user, args.from)); } - user = user || authenthifiers.speaker(user, args.from); + user = user || authentifiers.speaker(user, args.from); if(user){ res = res.concat(await connectors.getGroupJoinEventRequests(user, args.from)); res = res.concat(await connectors.getYourGroupHostEventRequests(user, args.from)); @@ -164,19 +165,19 @@ export const resolvers = { // Superviser mutations takeAdminRights : async function(obj, args, context){ - let user = await authenthifiers.superviser(user, args.from); + let user = await authentifiers.superviser(user, args.from); return user && await connectors.takeAdminRights(user, args.from, user.justification); }, releaseAdminRights : async function(obj, args, context){ - let user = await authenthifiers.superviser(user, args.from); + let user = await authentifiers.superviser(user, args.from); return user && await connectors.releaseAdminRights(user, args.from, user.justification); }, // Admin mutations createSubgroup: async function (obj, args, context){ - let user = authenthifiers.admin(context.user, args.from); + let user = authentifiers.admin(context.user, args.from); return user && connectors.createSubgroup(user, args); },