Skip to content

Commit 6b0ecd8

Browse files
committed
Update validation and DTO for employeeNumber field in inetOrgPerson
1 parent 73df13d commit 6b0ecd8

File tree

11 files changed

+38
-14
lines changed

11 files changed

+38
-14
lines changed

docs/technical/Tests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const inetOrgPersonDtoStub = (): inetOrgPersonDto => {
9595
cn: 'cn',
9696
sn: 'sn',
9797
uid: 'uid',
98+
employeeNumber: 'employeeNumber',
9899
displayName: 'displayName',
99100
facsimileTelephoneNumber: 'facsimileTelephoneNumber',
100101
givenName: 'givenName',

docs/user/IdentitiesCreation.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ Lors de la création d'une identité, le corps de la requête doit inclure les i
4242

4343
#### Informations de Base (`inetOrgPerson`)
4444

45-
Les informations de base de l'identité sont définies dans l'objet `inetOrgPerson`. Les champs requis sont `cn` (Nom Commun), `sn` (Nom de Famille), et `uid` (Identifiant Unique). Ces champs sont validés en dur.
45+
Les informations de base de l'identité sont définies dans l'objet `inetOrgPerson`. Les champs requis sont `cn` (Nom Commun), `sn` (Nom de Famille), `uid` (Identifiant Unique), et `employeeNumber` (Identifiant Identité). Ces champs sont validés en dur.
4646

4747
##### Champs obligatoires :
4848
- `cn`
4949
- `sn`
5050
- `uid`
51+
- `employeeNumber`
5152

5253
##### Champs facultatifs :
5354
- `displayName`
@@ -92,7 +93,8 @@ Voici un exemple de corps de requête pour la création d'une identité avec les
9293
"inetOrgPerson": {
9394
"cn": "Nom Commun",
9495
"sn": "Nom de Famille",
95-
"uid": "Identifiant Unique"
96+
"uid": "Identifiant Unique",
97+
"employeeNumber": "Identifiant Identité"
9698
},
9799
"additionalFields": {
98100
"objectClasses": ["supann"],
@@ -118,7 +120,8 @@ curl -X POST "http://<adresse-du-serveur>/identities" \
118120
"inetOrgPerson": {
119121
"cn": "Nom Commun",
120122
"sn": "Nom de Famille",
121-
"uid": "Identifiant Unique"
123+
"uid": "Identifiant Unique",
124+
"employeeNumber": "Identifiant Identité"
122125
},
123126
"additionalFields": {
124127
"objectClasses": ["supann"],
@@ -160,15 +163,16 @@ Même procédure pour la validation, mais ici nous avons :
160163

161164
### Corps de la Requête (Body)
162165

163-
Lors de la création d'une identité, le corps de la requête doit inclure au moins la données (`inetOrgPerson.uid`), ainsi que tout champ additionnel nécessaire selon l'`objectClass` spécifique. Notez que l'objet `inetOrgPerson` est validé en dur et non via un fichier YAML.
166+
Lors de la création d'une identité, le corps de la requête doit inclure au moins la données (`inetOrgPerson.uid`) et (`inetOrgPerson.employeeNumber`), ainsi que tout champ additionnel nécessaire selon l'`objectClass` spécifique. Notez que l'objet `inetOrgPerson` est validé en dur et non via un fichier YAML.
164167

165168
De plus pour une modification, il specifier le state a `-1`
166169

167170
```json
168171
{
169172
"state": -1,
170173
"inetOrgPerson": {
171-
"uid": "Identifiant Unique"
174+
"uid": "Identifiant Unique",
175+
"employeeNumber": "Identifiant Identite"
172176
},
173177
"additionalFields": {
174178
"objectClasses": ["supann"],
@@ -190,7 +194,8 @@ De plus pour une modification, il specifier le state a `-1`
190194
-d '{
191195
"state": -1,
192196
"inetOrgPerson": {
193-
"uid": "Identifiant Unique"
197+
"uid": "Identifiant Unique",
198+
"employeeNumber": "Identifiant Identite"
194199
},
195200
"additionalFields": {
196201
"objectClasses": ["supann"],

docs/user/IdentitiesValidation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Les champs de base de l'objet `inetOrgPerson` sont validés par défaut.
1313
- `cn`
1414
- `sn`
1515
- `uid`
16+
- `employeeNumber`
1617

1718
### Champs facultatifs :
1819
- `displayName`

src/management/identities/_dto/_parts/inetOrgPerson.dto.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ export class inetOrgPersonCreateDto {
88

99
@IsString()
1010
@ApiProperty()
11-
@IsOptional()
12-
cn?: string;
11+
employeeNumber: string;
1312

1413
@IsString()
1514
@ApiProperty()
@@ -78,6 +77,6 @@ export class inetOrgPersonCreateDto {
7877
userPassword?: string;
7978
}
8079

81-
export class inetOrgPersonDto extends inetOrgPersonCreateDto {}
80+
export class inetOrgPersonDto extends inetOrgPersonCreateDto { }
8281

83-
export class inetOrgPersonUpdateDto extends PartialType(inetOrgPersonCreateDto) {}
82+
export class inetOrgPersonUpdateDto extends PartialType(inetOrgPersonCreateDto) { }

src/management/identities/_schemas/_parts/inetOrgPerson.part.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export class inetOrgPerson {
4141
@Prop({ required: true, unique: true })
4242
uid: string;
4343

44+
@Prop({ required: true, unique: true })
45+
employeeNumber: string;
46+
4447
@Prop()
4548
userCertificate?: string;
4649

src/management/identities/_stubs/_parts/inetOrgPerson.dto.stub.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const inetOrgPersonDtoStub = (): inetOrgPersonDto => {
55
cn: 'cn',
66
sn: 'sn',
77
uid: 'uid',
8+
employeeNumber: 'employeeNumber',
89
displayName: 'displayName',
910
facsimileTelephoneNumber: 'facsimileTelephoneNumber',
1011
givenName: 'givenName',

src/management/identities/identities.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { inetOrgPerson } from './_schemas/_parts/inetOrgPerson.part';
21
import { HttpException, Injectable, Logger } from '@nestjs/common';
32
import { InjectModel } from '@nestjs/mongoose';
43
import { Identities } from './_schemas/identities.schema';
@@ -52,7 +51,6 @@ export class IdentitiesService extends AbstractServiceSchema {
5251
}
5352

5453
//TODO: ameliorer la logique d'upsert
55-
5654
if (identity) {
5755
this.logger.log(`${logPrefix} Identity already exists. Updating.`);
5856
data.inetOrgPerson = {
@@ -72,6 +70,7 @@ export class IdentitiesService extends AbstractServiceSchema {
7270
};
7371
}
7472

73+
//TODO: rechercher par uid ou employeeNumber ?
7574
const upsert = await super.upsert({ 'inetOrgPerson.uid': data.inetOrgPerson.uid }, data, options);
7675
return upsert;
7776
//TODO: add backends service logic here

src/management/identities/jsonforms/_config/inetorgperson.ui.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
"options": {
2929
"required": true
3030
}
31+
},
32+
{
33+
"type": "Control",
34+
"label": "EmployeeNumber",
35+
"scope": "#/properties/employeeNumber",
36+
"options": {
37+
"required": true
38+
}
3139
}
3240
]
3341
},

src/management/identities/validations/_config/inetorgperson.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"type": "string",
1515
"description": "UID of the inetOrgPerson."
1616
},
17+
"employeeNumber": {
18+
"type": "string",
19+
"description": "EmployeeNumber of the inetOrgPerson."
20+
},
1721
"displayName": {
1822
"type": "string",
1923
"description": "Display name of the inetOrgPerson."
@@ -64,5 +68,5 @@
6468
"description": "User password of the inetOrgPerson."
6569
}
6670
},
67-
"required": ["uid"]
71+
"required": ["uid", "employeeNumber"]
6872
}

src/management/passwd/passwd.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ResetPasswordDto } from './dto/reset-password.dto';
1313
export class PasswdController {
1414
private readonly logger = new Logger(PasswdController.name);
1515

16-
public constructor(private passwdService: PasswdService) {}
16+
public constructor(private passwdService: PasswdService) { }
1717

1818
@Post('change')
1919
@ApiOperation({ summary: 'change password' })
@@ -24,6 +24,7 @@ export class PasswdController {
2424
public async change(@Body() cpwd: ChangePasswordDto, @Res() res: Response): Promise<Response> {
2525
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2626
const [_, data] = await this.passwdService.change(cpwd);
27+
//TODO: uid ou employeeNumber ?
2728
data.data.uid = cpwd.id;
2829
this.logger.log(`call passwd change for : ${cpwd.id}`);
2930

0 commit comments

Comments
 (0)