diff --git a/src/config_passport.js b/src/config_passport.js index 89d3147f3b66c2e37aa582e80e1e5132e555c923..d8296e5c0f167ef916f59ef9ea74eb41b1a7a5b9 100644 --- a/src/config_passport.js +++ b/src/config_passport.js @@ -40,7 +40,7 @@ passport.use(new LdapStrategy({ url: ldapConfig.server, //bindDn: '.............', //bindCredentials: '..........', - searchBase: ldapConfig.dn_users, // this field cannot be left empty. + searchBase: ldapConfig.dn.user, // this field cannot be left empty. searchFilter: '(uid={{username}})', // this field cannot be left empty. searchAttributes: ['uid', 'urlPhoto'], // only fetch the uid, no need for any other field //tlsOptions: '..........', diff --git a/src/graphql/models/tools.ts b/src/graphql/models/tools.ts index 0f22268622244771df1025598511594e38ea975c..1e01268fa3f84e6a17b798cf72b982b2a0d792af 100644 --- a/src/graphql/models/tools.ts +++ b/src/graphql/models/tools.ts @@ -70,7 +70,8 @@ export class Tools { * @async */ static async memberOfSimple(data: userData): Promise<GroupSet> { - return new GroupSet(data.groups); + throw "Not implemented"; + return new GroupSet(data.members); } /** @@ -82,7 +83,9 @@ export class Tools { * @async */ static async speakerOfSimple(data: userData): Promise<GroupSet> { - throw "Not implemented"; + let speaker = new GroupSet(data.speakers); + speaker.addList(data.admins); + return speaker; } /** @@ -94,7 +97,8 @@ export class Tools { * @async */ static async adminOfSimple(data: userData): Promise<GroupSet> { - return new GroupSet(data.groupsIsAdmin); + throw "Not implemented"; + return new GroupSet(data.admins); } /** diff --git a/src/graphql/models/userModel.ts b/src/graphql/models/userModel.ts index 5e75ec16729220355af32438c1c2e91d7febf139..cad226216294b834df87910e00b5780554730217 100644 --- a/src/graphql/models/userModel.ts +++ b/src/graphql/models/userModel.ts @@ -47,18 +47,17 @@ export class UserModel { * @rights connectedOrOnplatal */ async searchTOL(args: searchTOLArgs): Promise<User[]> { + //TODO : correctly handle groups (in LDAP, a member can be stored as member, speaker or admin...) + const searchData = new userData(); searchData.givenName = args.givenName; searchData.lastName = args.lastName; searchData.nickname = args.nickname; searchData.nationality = args.nationality; - searchData.promotion = args.promotion; - searchData.groups = args.groups; - searchData.sport = args.sport; + searchData.members = args.groups; searchData.phone = args.phone; searchData.mail = args.mail; - searchData.address = args.addresses[0]; - searchData.ips = args.ips; + searchData.address = args.address; const userList = await UT.search(searchData); return userList.map((uid) => new User(uid)); @@ -79,26 +78,21 @@ export class UserModel { //Modify some fields, keep the others let editArgs = new userData(); editArgs.uid = data.uid; - editArgs.groups = data.groups; - editArgs.groupsIsAdmin = data.groupsIsAdmin; editArgs.password = data.password; editArgs.givenName = data.givenName; editArgs.lastName = data.lastName; editArgs.nickname = args.nickname; // <- this field is modified by user - editArgs.promotion = data.promotion; + editArgs.gender = data.gender; editArgs.photo = data.photo; - editArgs.birthdate = data.birthdate; - editArgs.nationality = data.nationality; editArgs.phone = args.phone; // <- this field is modified editArgs.address = data.address; // WTF why can't this be changed ???? editArgs.mail = args.mail; // <- this field is modified - editArgs.ips = data.ips; - editArgs.directory = data.directory; - editArgs.login = data.login; - editArgs.readPerm = data.readPerm; - editArgs.writePerm = data.writePerm; - editArgs.forlifes = data.forlifes; - editArgs.sport = data.sport; + editArgs.birthdate = data.birthdate; + editArgs.nationality = data.nationality; + editArgs.admins = data.admins; + editArgs.speakers = data.speakers; + editArgs.members = data.members; + editArgs.followers = data.followers; if(await UT.edit(editArgs)) { return new User(data.uid); diff --git a/src/graphql/object_resolvers/users.ts b/src/graphql/object_resolvers/users.ts index 28ee5f8fccb586fb89699fa70bc8fe584683e4d3..d20a29e80d55959a4a857f5468202c9202b06cf2 100644 --- a/src/graphql/object_resolvers/users.ts +++ b/src/graphql/object_resolvers/users.ts @@ -64,16 +64,15 @@ export class User { this.m_nickname = data.nickname; this.m_nationality = data.nationality; this.m_birthdate = data.birthdate; - this.m_promotion = data.promotion; this.m_mail = data.mail; this.m_phone = data.phone; - this.m_addresses = [data.address]; + this.m_address = data.address; - this.m_memberOf = data.groups; - //this.m_speakerOf = data.groupsIsSpeaker; - this.m_adminOf = data.groupsIsAdmin; - //this.m_likes = data.likes; + this.m_memberOf = data.members; + this.m_speakerOf = data.speakers; + this.m_adminOf = data.admins; + this.m_likes = data.followers; this.m_dataLoaded = true; return true; @@ -99,11 +98,10 @@ export class User { protected m_nickname: string protected m_nationality: string protected m_birthdate: string - protected m_promotion: string protected m_mail: string protected m_phone: string - protected m_addresses: string[] + protected m_address: string protected m_memberOf: string[] protected m_speakerOf: string[] @@ -192,7 +190,7 @@ export class User { */ async promotion(args, context: Context, info): Promise<string> { await this.fetchData(); - return this.m_promotion; + throw "Not implemented"; } /** @@ -223,15 +221,15 @@ export class User { /** * @memberof GraphQL.User# - * @function addresses - * @summary Renvoie les adresses - * @return {Promise(string[])} + * @function address + * @summary Renvoie l'adresse + * @return {Promise(string)} * @rights connectedOrOnplatal * @async */ - async addresses(args, context: Context, info): Promise<string[]> { + async address(args, context: Context, info): Promise<string> { await this.fetchData(); - return this.m_addresses; + return this.m_address; } /** diff --git a/src/graphql/typeDefs/actions.graphql b/src/graphql/typeDefs/actions.graphql index ff55539cae8778ca3114dc9029ccb34506255bf9..fbde0bedba444c94ac95413943fa38cce9305583 100644 --- a/src/graphql/typeDefs/actions.graphql +++ b/src/graphql/typeDefs/actions.graphql @@ -42,14 +42,11 @@ type Query { nickname: String, nationality: String, school: String, - promotion: String, groups: [String], studies: String, - sport: String, phone: String, mail: String, - addresses: [String], - ips: [String] + address: String ): [User!] } diff --git a/src/graphql/typeDefs/queries.d.ts b/src/graphql/typeDefs/queries.d.ts index 75c7b9517cbe074e38c4e3c4ad0ffd2a04a8915c..40b9e0cce36b9217bc15559ff6e556a08581fa4a 100644 --- a/src/graphql/typeDefs/queries.d.ts +++ b/src/graphql/typeDefs/queries.d.ts @@ -22,14 +22,11 @@ interface searchTOLArgs { nickname: string, nationality: string, school: string, - promotion: string, groups: string[], studies: string, - sport: string, phone: string, mail: string, - addresses: string[], - ips: string[] + address: string } interface editProfileArgs { diff --git a/src/ldap/export/user.ts b/src/ldap/export/user.ts index 3acebc168ab826081dc1f9dbafcb34918324e45e..8ab730bc17c46156f66aa065bf6182b60ab98243 100644 --- a/src/ldap/export/user.ts +++ b/src/ldap/export/user.ts @@ -11,6 +11,8 @@ import {Tools} from '../internal/tools'; // Classes à exporter TBT //------------------------------------------------------------------------------------------------------------------------ +export {userData}; + export class User { /** * @memberof LDAP diff --git a/src/ldap/internal/config.ts b/src/ldap/internal/config.ts index 548394b23355958d3ecdc0b946167bda11db9158..a5df4ee1e2787c0e83b9315b1992f7f683a64880 100644 --- a/src/ldap/internal/config.ts +++ b/src/ldap/internal/config.ts @@ -45,8 +45,8 @@ export const categories = ["admins","speakers","members","followers"]; * @var {string?} gender - Sexe * @var {string?} photo - Bytestring de la photo de l'utilisateur * @var {string?} phone - Numéro(s) de téléphone - * @var {string[]} address - Adresse(s) - * @var {string[]?} mail - Adresse(s) courriel + * @var {string?} address - Adresse(s) + * @var {string?} mail - Adresse(s) courriel * @var {string?} birthdate - Date d'anniversaire * @var {string?} nationality - Nationalité d'origine * @var {string[]?} admins - Liste des gid (group id, inclus section sportive, binet, PA...) dont l'utilisateur est admin ; pas forcément sous-liste de groups diff --git a/src/ldap/internal/tools.ts b/src/ldap/internal/tools.ts index 6f57fa240827fd5e0c5e7ab797cecd1c377253c7..507d909a9384b0ee5ff2e84fa2347c23e5e07395 100644 --- a/src/ldap/internal/tools.ts +++ b/src/ldap/internal/tools.ts @@ -38,12 +38,13 @@ export class Tools { let cleanData : T = new type(); let attr = Object.keys(dirtyKeys).map(key => dirtyKeys[key]); //console.log(attr); - let dirtyData = await Basics.searchMultiple(domain, attr, id); - //console.log(dirtyData[0]); + let dirtyData = (await Basics.searchMultiple(domain, attr, id))[0]; + console.log(dirtyData); + console.log(cleanData); // Rename output - for (let uncleanKey in dirtyData[0]) { + for (let uncleanKey in dirtyData) { for (let cleanKey of Object.keys(cleanData)) { - //console.log(cleanKey); + console.log(cleanKey); if (uncleanKey==dirtyKeys[cleanKey]) { cleanData[cleanKey] = dirtyData[uncleanKey]; } } }