File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
apps/api/src/management/identities Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -325,28 +325,26 @@ export abstract class AbstractIdentitiesService extends AbstractServiceSchema {
325325 * @returns true si l'email et l'UID sont uniques, false sinon
326326 */
327327 protected async checkMailAndUid ( data : IdentitiesUpsertDto | any ) : Promise < boolean > {
328- // Validation des paramètres d'entrée
329- if ( ! data ?. _id ) {
330- throw new BadRequestException ( 'ID is required for mail and UID uniqueness check' ) ;
331- }
332-
333328 if ( ! data ?. inetOrgPerson ?. uid ) {
334329 throw new BadRequestException ( 'UID is required for mail and UID uniqueness check' ) ;
335330 }
336331
337332 // Validation du format de l'ID
338333 let objectId : Types . ObjectId ;
339- try {
340- objectId = Types . ObjectId . createFromHexString ( data . _id ) ;
341- } catch ( error ) {
342- throw new BadRequestException ( 'Invalid ID format' ) ;
334+ if ( data . _id !== undefined && data . _id !== null ) {
335+ try {
336+ objectId = Types . ObjectId . createFromHexString ( data . _id ) ;
337+ } catch ( error ) {
338+ throw new BadRequestException ( 'Invalid ID format' ) ;
339+ }
343340 }
344341
345342 try {
346343 let duplicates : Identities [ ] = [ ] ;
347344
348345 // Vérification avec email si celui-ci est fourni et non vide
349346 if ( data . inetOrgPerson . hasOwnProperty ( 'mail' ) && data . inetOrgPerson . mail !== '' ) {
347+
350348 // Validation du format email
351349 if ( typeof data . inetOrgPerson . mail !== 'string' ) {
352350 throw new BadRequestException ( 'Invalid email format' ) ;
You can’t perform that action at this time.
0 commit comments