Skip to content

Commit 530a041

Browse files
authored
Merge pull request #17 from Libertech-FR/formsui
add news prerequisites
2 parents 354ea60 + 24f038c commit 530a041

File tree

7 files changed

+133
-8
lines changed

7 files changed

+133
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ docker/docker-compose.yml
3838
docker/docker-compose.yml
3939

4040
documentation/*
41+
.dev-token.json

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
yarn lint:fix
1+
#yarn lint:fix
22
#yarn test

src/core/auth/auth.service.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ForbiddenException, Injectable, Logger, OnModuleInit, UnauthorizedException } from '@nestjs/common';
1+
import { ForbiddenException, Injectable, OnModuleInit, UnauthorizedException } from '@nestjs/common';
22
import { AbstractService } from '~/_common/abstracts/abstract.service';
33
import { ModuleRef } from '@nestjs/core';
44
import { Redis } from 'ioredis';
@@ -11,6 +11,9 @@ import { AgentType } from '~/_common/types/agent.type';
1111
import { omit } from 'radash';
1212
import { JwtPayload } from 'jsonwebtoken';
1313
import { JwtService } from '@nestjs/jwt';
14+
import { resolve } from 'path';
15+
import { existsSync, readFileSync, writeFileSync } from 'fs';
16+
import { ConsoleSession } from '~/_common/data/console-session';
1417

1518
@Injectable()
1619
export class AuthService extends AbstractService implements OnModuleInit {
@@ -32,8 +35,33 @@ export class AuthService extends AbstractService implements OnModuleInit {
3235
super();
3336
}
3437

35-
onModuleInit(): any {
36-
Logger.log('Auth service initialized');
38+
public async onModuleInit(): Promise<void> {
39+
if (process.env.NODE_ENV !== 'production') {
40+
this.logger.warn('DEV MODE ENABLED !');
41+
const devTokenPath = resolve(process.cwd(), this.DEV_TOKEN_PATH);
42+
if (existsSync(devTokenPath)) {
43+
try {
44+
const data = JSON.parse(readFileSync(devTokenPath, 'utf-8'));
45+
if (data.access_token) {
46+
this.logger.log(`TOKEN ALREADY EXIST : <${data.access_token}>`);
47+
return;
48+
}
49+
} catch (e) {
50+
this.logger.error(`TOKEN FILE CORRUPTED ! REGENERATING...`);
51+
}
52+
}
53+
const { access_token } = await this.createTokens(new ConsoleSession(), false, {
54+
expiresIn: '1y',
55+
});
56+
writeFileSync(
57+
devTokenPath,
58+
JSON.stringify({
59+
access_token,
60+
}),
61+
);
62+
63+
this.logger.log(`NEW TOKEN CREATED : <${access_token}>`);
64+
}
3765
}
3866

3967
public async authenticateWithLocal(username: string, password: string): Promise<Agents | null> {

src/core/logger/internal.logger.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { ConsoleLogger } from '@nestjs/common';
2+
3+
export class InternalLogger extends ConsoleLogger {
4+
public constructor() {
5+
super();
6+
}
7+
8+
// error(message: any, stack?: string, context?: string) {
9+
// // @ts-ignore
10+
// super.error(...arguments);
11+
// }
12+
//
13+
// warn(message: any, context?: string) {
14+
// // @ts-ignore
15+
// super.warn(...arguments);
16+
// }
17+
//
18+
// log(message: any, context?: string) {
19+
// // @ts-ignore
20+
// super.log(...arguments);
21+
// }
22+
//
23+
// debug(message: any, context?: string) {
24+
// // @ts-ignore
25+
// super.debug(...arguments);
26+
// }
27+
//
28+
// verbose(message: any, context?: string) {
29+
// // @ts-ignore
30+
// super.verbose(...arguments);
31+
// }
32+
//
33+
// fatal(message: any, context?: string) {
34+
// // @ts-ignore
35+
// super.error(...arguments);
36+
// }
37+
}

src/management/identities/identities.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class IdentitiesService extends AbstractServiceSchema {
1717
): Promise<Document<T, any, T>> {
1818
// noinspection UnnecessaryLocalVariableJS
1919
const created: Document<T, any, T> = await super.create(data, options);
20-
//TODO: add backends service logic here
20+
//TODO: add backends service logic here (TO_SYNC)
2121
return created;
2222
}
2323

@@ -28,7 +28,7 @@ export class IdentitiesService extends AbstractServiceSchema {
2828
): Promise<ModifyResult<Query<T, T, any, T>>> {
2929
// noinspection UnnecessaryLocalVariableJS
3030
const updated = await super.update(_id, update, options);
31-
//TODO: add backends service logic here
31+
//TODO: add backends service logic here (TO_SYNC)
3232
return updated;
3333
}
3434

@@ -37,8 +37,9 @@ export class IdentitiesService extends AbstractServiceSchema {
3737
options?: QueryOptions<T> | null | undefined,
3838
): Promise<Query<T, T, any, T>> {
3939
// noinspection UnnecessaryLocalVariableJS
40+
//TODO: soft delete
4041
const deleted = await super.delete(_id, options);
41-
//TODO: add backends service logic here
42+
//TODO: add backends service logic here (TO_SYNC)
4243
return deleted;
4344
}
4445
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
form:
2+
type: VerticalLayout
3+
elements:
4+
- type: Control
5+
scope: "#/properties/supannEmpId"
6+
label: "Employee ID"
7+
- type: Control
8+
scope: "#/properties/supannCivilite"
9+
label: "Title (Mr, Ms, etc.)"
10+
- type: Control
11+
scope: "#/properties/supannBirthName"
12+
label: "Birth name"
13+
- type: Control
14+
scope: "#/properties/supannBirthDate"
15+
label: "Date of birth"
16+
- type: Control
17+
scope: "#/properties/supannBirthPlace"
18+
label: "Place of birth"
19+
- type: Control
20+
scope: "#/properties/supannMailPerso"
21+
label: "Personal email"
22+
- type: Control
23+
scope: "#/properties/supannMailPro"
24+
label: "Professional email"
25+
- type: Control
26+
scope: "#/properties/supannTelPerso"
27+
label: "Personal phone number"
28+
- type: Control
29+
scope: "#/properties/supannTelPro"
30+
label: "Professional phone number"
31+
- type: Control
32+
scope: "#/properties/supannPostalAddress"
33+
label: "Postal address"
34+
- type: Control
35+
scope: "#/properties/supannRole"
36+
label: "Role in the organization"
37+
- type: Control
38+
scope: "#/properties/supannStatus"
39+
label: "Employment status"
40+
- type: Control
41+
scope: "#/properties/supannEtablissement"
42+
label: "Institution"
43+
- type: Control
44+
scope: "#/properties/supannAffectationPrincipale"
45+
label: "Primary assignment"
46+
- type: Control
47+
scope: "#/properties/supannAffectationSecondaire"
48+
label: "Secondary assignment"
49+
- type: Control
50+
scope: "#/properties/supannCodeINE"
51+
label: "National Education Identifier"

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8845,13 +8845,20 @@ semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
88458845
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
88468846
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
88478847

8848-
semver@^7.0.0, semver@^7.1.1, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4:
8848+
semver@^7.0.0, semver@^7.1.1, semver@^7.3.4, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4:
88498849
version "7.5.4"
88508850
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
88518851
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
88528852
dependencies:
88538853
lru-cache "^6.0.0"
88548854

8855+
semver@^7.3.5:
8856+
version "7.6.0"
8857+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
8858+
integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==
8859+
dependencies:
8860+
lru-cache "^6.0.0"
8861+
88558862
send@0.18.0, send@latest:
88568863
version "0.18.0"
88578864
resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"

0 commit comments

Comments
 (0)