rez_core 1.0.25 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/250218_nodejs_core.iml +12 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/dataSources.xml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/dist/app.module.d.ts +0 -0
- package/dist/app.module.js +1 -0
- package/dist/app.module.js.map +1 -0
- package/dist/config/database.config.d.ts +3 -0
- package/dist/config/database.config.js +14 -6
- package/dist/config/database.config.js.map +1 -1
- package/dist/constant/global.constant.d.ts +6 -2
- package/dist/constant/global.constant.js +7 -3
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/dist/module/auth/auth.module.js +1 -1
- package/dist/module/auth/auth.module.js.map +1 -1
- package/dist/module/auth/guards/role.guard.js +3 -3
- package/dist/module/auth/strategies/google.strategy.d.ts +3 -1
- package/dist/module/auth/strategies/google.strategy.js +7 -5
- package/dist/module/auth/strategies/google.strategy.js.map +1 -1
- package/dist/module/auth/strategies/jwt.strategy.d.ts +4 -4
- package/dist/module/auth/strategies/jwt.strategy.js +8 -9
- package/dist/module/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/module/meta/entity/base-entity.entity.d.ts +1 -2
- package/dist/module/meta/entity/base-entity.entity.js +1 -2
- package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-master.entity.d.ts +1 -0
- package/dist/module/meta/entity/entity-master.entity.js +4 -0
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/entity/media-data.entity.d.ts +11 -0
- package/dist/module/meta/entity/media-data.entity.js +55 -0
- package/dist/module/meta/entity/media-data.entity.js.map +1 -0
- package/dist/module/meta/entity.module.js +8 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/media-data.repository.d.ts +9 -0
- package/dist/module/meta/repository/media-data.repository.js +55 -0
- package/dist/module/meta/repository/media-data.repository.js.map +1 -0
- package/dist/module/meta/service/entity-list.service.d.ts +1 -0
- package/dist/module/meta/service/entity-list.service.js +14 -2
- package/dist/module/meta/service/entity-list.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +21 -4
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/media-data.service.d.ts +9 -0
- package/dist/module/meta/service/media-data.service.js +36 -0
- package/dist/module/meta/service/media-data.service.js.map +1 -0
- package/dist/module/module/entity/menu.entity.d.ts +1 -2
- package/dist/module/module/entity/menu.entity.js +1 -2
- package/dist/module/module/entity/menu.entity.js.map +1 -1
- package/dist/module/module/entity/module.entity.d.ts +1 -2
- package/dist/module/module/entity/module.entity.js +1 -2
- package/dist/module/module/entity/module.entity.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +5 -3
- package/dist/module/notification/controller/otp.controller.js +7 -4
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/service/otp.service.d.ts +5 -3
- package/dist/module/notification/service/otp.service.js +7 -4
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +4 -2
- package/dist/module/user/service/login.service.js +8 -6
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +5 -3
- package/dist/module/user/service/user.service.js +10 -6
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/resources/dev.properties.yaml +15 -0
- package/dist/resources/properties.module.d.ts +2 -0
- package/dist/resources/properties.module.js +25 -0
- package/dist/resources/properties.module.js.map +1 -0
- package/dist/resources/properties.yaml.d.ts +2 -0
- package/dist/resources/properties.yaml.js +10 -0
- package/dist/resources/properties.yaml.js.map +1 -0
- package/dist/resources/uat.properties.yaml +15 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nest-cli.json +6 -0
- package/package.json +1 -1
- package/src/app.module.ts +0 -0
- package/src/config/database.config.ts +10 -5
- package/src/constant/global.constant.ts +13 -4
- package/src/module/auth/auth.module.ts +3 -2
- package/src/module/auth/guards/jwt.guard.ts +22 -22
- package/src/module/auth/guards/role.guard.ts +68 -68
- package/src/module/auth/services/auth.service.ts +29 -29
- package/src/module/auth/services/jwt.service.ts +11 -11
- package/src/module/auth/strategies/google.strategy.ts +7 -4
- package/src/module/auth/strategies/jwt.strategy.ts +5 -6
- package/src/module/auth/strategies/local.strategy.ts +13 -13
- package/src/module/dev/dev.module.ts +12 -12
- package/src/module/dev/service/dev.service.ts +7 -7
- package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
- package/src/module/enterprise/entity/organization.entity.ts +80 -80
- package/src/module/master/controller/master.controller.ts +22 -22
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/entity/attribute-master.entity.ts +67 -67
- package/src/module/meta/entity/base-entity.entity.ts +1 -2
- package/src/module/meta/entity/entity-master.entity.ts +3 -0
- package/src/module/meta/entity/media-data.entity.ts +32 -0
- package/src/module/meta/entity/preference.entity.ts +65 -65
- package/src/module/meta/entity.module.ts +8 -1
- package/src/module/meta/repository/attribute-master.repository.ts +28 -28
- package/src/module/meta/repository/media-data.repository.ts +50 -0
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/meta/service/entity-list.service.ts +21 -2
- package/src/module/meta/service/entity-service-impl.service.ts +36 -11
- package/src/module/meta/service/media-data.service.ts +44 -0
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/entity/menu.entity.ts +1 -2
- package/src/module/module/entity/module-access.entity.ts +22 -22
- package/src/module/module/entity/module-action.entity.ts +19 -19
- package/src/module/module/entity/module.entity.ts +1 -2
- package/src/module/notification/controller/otp.controller.ts +8 -3
- package/src/module/notification/service/otp.service.ts +6 -3
- package/src/module/user/controller/user.controller.ts +28 -28
- package/src/module/user/dto/update-user.dto.ts +4 -4
- package/src/module/user/entity/user-role-mapping.entity.ts +21 -21
- package/src/module/user/entity/user-session.entity.ts +61 -61
- package/src/module/user/entity/user.entity.ts +35 -35
- package/src/module/user/repository/role.repository.ts +16 -16
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/module/user/service/login.service.ts +8 -6
- package/src/module/user/service/user.service.ts +10 -7
- package/src/resources/dev.properties.yaml +15 -0
- package/src/resources/properties.module.ts +12 -0
- package/src/resources/properties.yaml.ts +11 -0
- package/src/resources/uat.properties.yaml +15 -0
- package/src/utils/service/encryptUtil.service.ts +97 -97
- package/src/utils/service/excelUtil.service.ts +15 -15
- package/src/utils/service/reflection-helper.service.ts +53 -53
- package/.env +0 -10
- package/dist/constant/status.constant.d.ts +0 -4
- package/dist/constant/status.constant.js +0 -9
- package/dist/constant/status.constant.js.map +0 -1
- package/src/constant/status.constant.ts +0 -3
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'cr_user_session' })
|
|
4
|
-
export class UserSession {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@Column({
|
|
9
|
-
name: 'is_session_loggedout',
|
|
10
|
-
nullable: true,
|
|
11
|
-
type: 'int',
|
|
12
|
-
})
|
|
13
|
-
is_session_loggedout: number;
|
|
14
|
-
|
|
15
|
-
@Column({
|
|
16
|
-
name: 'login_id',
|
|
17
|
-
nullable: true,
|
|
18
|
-
length: 50,
|
|
19
|
-
})
|
|
20
|
-
login_id: string;
|
|
21
|
-
|
|
22
|
-
@Column({
|
|
23
|
-
name: 'login_time',
|
|
24
|
-
nullable: true,
|
|
25
|
-
})
|
|
26
|
-
login_time: Date;
|
|
27
|
-
|
|
28
|
-
@Column({
|
|
29
|
-
name: 'logout_time',
|
|
30
|
-
nullable: true,
|
|
31
|
-
})
|
|
32
|
-
logout_time: Date;
|
|
33
|
-
|
|
34
|
-
@Column({
|
|
35
|
-
name: 'session_key',
|
|
36
|
-
nullable: true,
|
|
37
|
-
length: 100,
|
|
38
|
-
})
|
|
39
|
-
session_key: string;
|
|
40
|
-
|
|
41
|
-
@Column({
|
|
42
|
-
name: 'user_id',
|
|
43
|
-
nullable: true,
|
|
44
|
-
type: 'bigint',
|
|
45
|
-
})
|
|
46
|
-
user_id: number;
|
|
47
|
-
|
|
48
|
-
@Column({
|
|
49
|
-
name: 'access_token',
|
|
50
|
-
nullable: true,
|
|
51
|
-
type: 'varchar',
|
|
52
|
-
length: 5000,
|
|
53
|
-
})
|
|
54
|
-
access_token: string;
|
|
55
|
-
|
|
56
|
-
@Column({
|
|
57
|
-
name: 'expiry_date',
|
|
58
|
-
nullable: true,
|
|
59
|
-
})
|
|
60
|
-
expiry_date: Date;
|
|
61
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_user_session' })
|
|
4
|
+
export class UserSession {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({
|
|
9
|
+
name: 'is_session_loggedout',
|
|
10
|
+
nullable: true,
|
|
11
|
+
type: 'int',
|
|
12
|
+
})
|
|
13
|
+
is_session_loggedout: number;
|
|
14
|
+
|
|
15
|
+
@Column({
|
|
16
|
+
name: 'login_id',
|
|
17
|
+
nullable: true,
|
|
18
|
+
length: 50,
|
|
19
|
+
})
|
|
20
|
+
login_id: string;
|
|
21
|
+
|
|
22
|
+
@Column({
|
|
23
|
+
name: 'login_time',
|
|
24
|
+
nullable: true,
|
|
25
|
+
})
|
|
26
|
+
login_time: Date;
|
|
27
|
+
|
|
28
|
+
@Column({
|
|
29
|
+
name: 'logout_time',
|
|
30
|
+
nullable: true,
|
|
31
|
+
})
|
|
32
|
+
logout_time: Date;
|
|
33
|
+
|
|
34
|
+
@Column({
|
|
35
|
+
name: 'session_key',
|
|
36
|
+
nullable: true,
|
|
37
|
+
length: 100,
|
|
38
|
+
})
|
|
39
|
+
session_key: string;
|
|
40
|
+
|
|
41
|
+
@Column({
|
|
42
|
+
name: 'user_id',
|
|
43
|
+
nullable: true,
|
|
44
|
+
type: 'bigint',
|
|
45
|
+
})
|
|
46
|
+
user_id: number;
|
|
47
|
+
|
|
48
|
+
@Column({
|
|
49
|
+
name: 'access_token',
|
|
50
|
+
nullable: true,
|
|
51
|
+
type: 'varchar',
|
|
52
|
+
length: 5000,
|
|
53
|
+
})
|
|
54
|
+
access_token: string;
|
|
55
|
+
|
|
56
|
+
@Column({
|
|
57
|
+
name: 'expiry_date',
|
|
58
|
+
nullable: true,
|
|
59
|
+
})
|
|
60
|
+
expiry_date: Date;
|
|
61
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Column, Entity } from 'typeorm';
|
|
2
|
-
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
3
|
-
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
4
|
-
|
|
5
|
-
@Entity({ name: 'cr_user' })
|
|
6
|
-
export class UserData extends BaseEntity {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.entity_type = ENTITYTYPE_USER;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
13
|
-
first_name: string;
|
|
14
|
-
|
|
15
|
-
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
16
|
-
last_name: string;
|
|
17
|
-
|
|
18
|
-
@Column({ type: 'varchar', length: 200, nullable: true })
|
|
19
|
-
password: string;
|
|
20
|
-
|
|
21
|
-
@Column({ type: 'varchar', length: 200, nullable: true })
|
|
22
|
-
email_id: string;
|
|
23
|
-
|
|
24
|
-
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
25
|
-
mobile: string;
|
|
26
|
-
|
|
27
|
-
@Column({ type: 'int', nullable: true })
|
|
28
|
-
is_firstlogin: number;
|
|
29
|
-
|
|
30
|
-
@Column({ type: 'int', width: 1, nullable: true })
|
|
31
|
-
is_defaultadmin: number;
|
|
32
|
-
|
|
33
|
-
@Column({ type: 'int', width: 1, nullable: true })
|
|
34
|
-
is_customer: number;
|
|
35
|
-
}
|
|
1
|
+
import { Column, Entity } from 'typeorm';
|
|
2
|
+
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
3
|
+
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
4
|
+
|
|
5
|
+
@Entity({ name: 'cr_user' })
|
|
6
|
+
export class UserData extends BaseEntity {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.entity_type = ENTITYTYPE_USER;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
13
|
+
first_name: string;
|
|
14
|
+
|
|
15
|
+
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
16
|
+
last_name: string;
|
|
17
|
+
|
|
18
|
+
@Column({ type: 'varchar', length: 200, nullable: true })
|
|
19
|
+
password: string;
|
|
20
|
+
|
|
21
|
+
@Column({ type: 'varchar', length: 200, nullable: true })
|
|
22
|
+
email_id: string;
|
|
23
|
+
|
|
24
|
+
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
25
|
+
mobile: string;
|
|
26
|
+
|
|
27
|
+
@Column({ type: 'int', nullable: true })
|
|
28
|
+
is_firstlogin: number;
|
|
29
|
+
|
|
30
|
+
@Column({ type: 'int', width: 1, nullable: true })
|
|
31
|
+
is_defaultadmin: number;
|
|
32
|
+
|
|
33
|
+
@Column({ type: 'int', width: 1, nullable: true })
|
|
34
|
+
is_customer: number;
|
|
35
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { Repository } from 'typeorm';
|
|
3
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
4
|
-
import { Role } from '../entity/role.entity';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class RoleRepository {
|
|
8
|
-
constructor(
|
|
9
|
-
@InjectRepository(Role)
|
|
10
|
-
private readonly roleRepo: Repository<Role>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findByCode(code: string): Promise<Role | null> {
|
|
14
|
-
return this.roleRepo.findOne({ where: { code } });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
4
|
+
import { Role } from '../entity/role.entity';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class RoleRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(Role)
|
|
10
|
+
private readonly roleRepo: Repository<Role>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findByCode(code: string): Promise<Role | null> {
|
|
14
|
+
return this.roleRepo.findOne({ where: { code } });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Repository } from 'typeorm';
|
|
2
|
-
import { UserSession } from '../entity/user-session.entity';
|
|
3
|
-
import { Injectable } from '@nestjs/common';
|
|
4
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class UserSessionRepository {
|
|
8
|
-
constructor(
|
|
9
|
-
@InjectRepository(UserSession)
|
|
10
|
-
private userSessionRepo: Repository<UserSession>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findBySessionKey(sessionKey: string): Promise<UserSession | null> {
|
|
14
|
-
return this.userSessionRepo.findOne({ where: { session_key: sessionKey } });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async findActiveSessionByUserId(userId: number): Promise<UserSession | null> {
|
|
18
|
-
return this.userSessionRepo.findOne({
|
|
19
|
-
where: { user_id: userId, is_session_loggedout: 0 },
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async saveSession(session: UserSession): Promise<UserSession> {
|
|
24
|
-
return this.userSessionRepo.save(session);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async logoutSession(sessionKey: string): Promise<void> {
|
|
28
|
-
await this.userSessionRepo.update(
|
|
29
|
-
{ session_key: sessionKey },
|
|
30
|
-
{ is_session_loggedout: 1, logout_time: new Date() },
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { UserSession } from '../entity/user-session.entity';
|
|
3
|
+
import { Injectable } from '@nestjs/common';
|
|
4
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class UserSessionRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(UserSession)
|
|
10
|
+
private userSessionRepo: Repository<UserSession>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findBySessionKey(sessionKey: string): Promise<UserSession | null> {
|
|
14
|
+
return this.userSessionRepo.findOne({ where: { session_key: sessionKey } });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async findActiveSessionByUserId(userId: number): Promise<UserSession | null> {
|
|
18
|
+
return this.userSessionRepo.findOne({
|
|
19
|
+
where: { user_id: userId, is_session_loggedout: 0 },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async saveSession(session: UserSession): Promise<UserSession> {
|
|
24
|
+
return this.userSessionRepo.save(session);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async logoutSession(sessionKey: string): Promise<void> {
|
|
28
|
+
await this.userSessionRepo.update(
|
|
29
|
+
{ session_key: sessionKey },
|
|
30
|
+
{ is_session_loggedout: 1, logout_time: new Date() },
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -3,6 +3,8 @@ import { EncryptUtilService } from '../../../utils/service/encryptUtil.service';
|
|
|
3
3
|
import { UserData } from '../entity/user.entity';
|
|
4
4
|
import { UserSessionService } from './user-session.service';
|
|
5
5
|
import { UserService } from './user.service';
|
|
6
|
+
import { ConfigService } from '@nestjs/config';
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
@Injectable()
|
|
@@ -10,13 +12,13 @@ export class LoginService {
|
|
|
10
12
|
constructor(
|
|
11
13
|
@Inject('UserService') private readonly userService: UserService,
|
|
12
14
|
private userSessionService: UserSessionService,
|
|
15
|
+
private configService: ConfigService
|
|
13
16
|
) {}
|
|
14
|
-
|
|
15
|
-
masterKey: string =
|
|
16
|
-
masterIv: string =
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
masterKey: string = this.configService.get('MASTER_KEY') || '';
|
|
19
|
+
masterIv: string = this.configService.get('MASTER_IV') || '';
|
|
20
|
+
|
|
18
21
|
async login(email: string, password: string) {
|
|
19
|
-
console.log(process.env.master_key)
|
|
20
22
|
const user = await this.userService.findByEmailId(email);
|
|
21
23
|
if (!user) {
|
|
22
24
|
return {
|
|
@@ -40,7 +42,7 @@ export class LoginService {
|
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
const token =
|
|
45
|
+
const token = await this.userSessionService.createSession(user);
|
|
44
46
|
|
|
45
47
|
return{
|
|
46
48
|
success:true,
|
|
@@ -5,27 +5,30 @@ import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
|
5
5
|
import { UserRepository } from '../repository/user.repository';
|
|
6
6
|
import { EncryptUtilService } from '../../../utils/service/encryptUtil.service';
|
|
7
7
|
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
8
|
-
import { ENTITYTYPE_ROLE } from '../../../constant/global.constant';
|
|
8
|
+
import { ENTITYTYPE_ROLE, STATUS_ACTIVE } from '../../../constant/global.constant';
|
|
9
9
|
import { CreateUserDto } from '../dto/create-user.dto';
|
|
10
10
|
import { UserRoleMappingService } from './user-role-mapping.service';
|
|
11
11
|
import { UserRoleMapping } from '../entity/user-role-mapping.entity';
|
|
12
12
|
import { plainToInstance } from 'class-transformer';
|
|
13
13
|
import { EntityManager } from 'typeorm';
|
|
14
14
|
import { UpdateUserDto } from '../dto/update-user.dto';
|
|
15
|
+
import { ConfigService } from '@nestjs/config';
|
|
15
16
|
|
|
16
17
|
@Injectable()
|
|
17
18
|
export class UserService extends EntityServiceImpl {
|
|
18
|
-
masterKey = process.env.master_key || '';
|
|
19
|
-
masterIv = process.env.master_iv || '';
|
|
20
|
-
|
|
21
19
|
constructor(
|
|
22
20
|
private userRepository: UserRepository,
|
|
23
21
|
private userRoleMappingService: UserRoleMappingService,
|
|
24
22
|
private readonly clockIDGenService: ClockIDGenService,
|
|
23
|
+
private configService: ConfigService,
|
|
25
24
|
) {
|
|
26
25
|
super();
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
masterKey = this.configService.get('MASTER_KEY') || '';
|
|
29
|
+
masterIv = this.configService.get('MASTER_IV') || '';
|
|
30
|
+
|
|
31
|
+
|
|
29
32
|
async createEntity(
|
|
30
33
|
entityData: BaseEntity,
|
|
31
34
|
loggedInUser: UserData | null,
|
|
@@ -60,11 +63,11 @@ export class UserService extends EntityServiceImpl {
|
|
|
60
63
|
);
|
|
61
64
|
}
|
|
62
65
|
userData.password = password;
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
userData.status = STATUS_ACTIVE;
|
|
67
|
+
const savedData = await super.createEntity(userData, loggedInUser);
|
|
65
68
|
if (userData.roles) {
|
|
66
69
|
let roles = userData.roles;
|
|
67
|
-
this.userRoleMappingService.deleteByUserId(userData.id);
|
|
70
|
+
await this.userRoleMappingService.deleteByUserId(userData.id);
|
|
68
71
|
for (const role in roles) {
|
|
69
72
|
let userRoleMapping = new UserRoleMapping(
|
|
70
73
|
savedData.id,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
DB_HOST: "13.234.25.234"
|
|
2
|
+
DB_PORT: "3306"
|
|
3
|
+
DB_USER: "root"
|
|
4
|
+
DB_PASS: "Rezolut@123"
|
|
5
|
+
DB_NAME: "core"
|
|
6
|
+
MASTER_KEY: "0QZ2eRJv5oVILYnyBlC+FbSGVQiWKReh"
|
|
7
|
+
MASTER_IV: "heuUQf5uPVtkotrFAOKUVw=="
|
|
8
|
+
SECRET_KEY: "1hard_to_guess_secret7890a"
|
|
9
|
+
CLIENT_ID: "324529881356-596sc8ksrb9lg01i7sktofqqqf0fv2ug.apps.googleusercontent.com"
|
|
10
|
+
CLIENT_SECRET: "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"
|
|
11
|
+
CALLBACK_URL: "http://localhost:3000/auth/google/callback"
|
|
12
|
+
OTP_EXPIRY: "10"
|
|
13
|
+
OTP_LENGTH: "6"
|
|
14
|
+
VERIFY_OTP: "false"
|
|
15
|
+
DEFAULT_OTP: "123456"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Module } from "@nestjs/common";
|
|
2
|
+
import { ConfigModule } from "@nestjs/config";
|
|
3
|
+
import propertiesYaml from "./properties.yaml";
|
|
4
|
+
@Module({
|
|
5
|
+
imports: [
|
|
6
|
+
ConfigModule.forRoot({
|
|
7
|
+
load: [propertiesYaml],
|
|
8
|
+
isGlobal: true
|
|
9
|
+
})
|
|
10
|
+
],
|
|
11
|
+
})
|
|
12
|
+
export default class Properties { }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import * as yaml from 'js-yaml';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
const YAML_CONFIG = `/dev.properties.yaml`;
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
return yaml.load(
|
|
9
|
+
readFileSync(join(__dirname, YAML_CONFIG), 'utf8'),
|
|
10
|
+
) as Record<string, any>
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
DB_HOST: "13.234.25.234"
|
|
2
|
+
DB_PORT: "3306"
|
|
3
|
+
DB_USER: "root"
|
|
4
|
+
DB_PASS: "Rezolut@123"
|
|
5
|
+
DB_NAME: "ether_core"
|
|
6
|
+
MASTER_KEY: "0QZ2eRJv5oVILYnyBlC+FbSGVQiWKReh"
|
|
7
|
+
MASTER_IV: "heuUQf5uPVtkotrFAOKUVw=="
|
|
8
|
+
SECRET_KEY: "1hard_to_guess_secret7890a"
|
|
9
|
+
CLIENT_ID: "324529881356-596sc8ksrb9lg01i7sktofqqqf0fv2ug.apps.googleusercontent.com"
|
|
10
|
+
CLIENT_SECRET: "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"
|
|
11
|
+
CALLBACK_URL: "http://localhost:3000/auth/google/callback"
|
|
12
|
+
OTP_EXPIRY: "10"
|
|
13
|
+
OTP_LENGTH: "6"
|
|
14
|
+
VERIFY_OTP: "false"
|
|
15
|
+
DEFAULT_OTP: "123456"
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
-
import * as crypto from 'crypto';
|
|
3
|
-
|
|
4
|
-
const CryptoJS = require('crypto-js');
|
|
5
|
-
const encryptionType = 'aes-256-cbc';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class EncryptUtilService {
|
|
9
|
-
constructor() {}
|
|
10
|
-
|
|
11
|
-
static encryptGCM(data: any, Datakey: string, Dataiv: string) {
|
|
12
|
-
try {
|
|
13
|
-
const cipher = crypto.createCipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
14
|
-
let encrypted = Buffer.concat([
|
|
15
|
-
cipher.update(data, 'utf8'),
|
|
16
|
-
cipher.final(),
|
|
17
|
-
]);
|
|
18
|
-
const tag = cipher.getAuthTag();
|
|
19
|
-
return Buffer.concat([encrypted, tag]).toString('base64');
|
|
20
|
-
} catch (error) {
|
|
21
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static decryptGCM(data: any, Datakey: any, Dataiv: any) {
|
|
26
|
-
try {
|
|
27
|
-
data = Buffer.from(data, 'base64');
|
|
28
|
-
const decipher = crypto.createDecipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
29
|
-
const tag = data.slice(data.length - 16);
|
|
30
|
-
decipher.setAuthTag(tag);
|
|
31
|
-
data = data.slice(0, data.length - 16);
|
|
32
|
-
let decrypted = decipher.update(data, 'utf8') + decipher.final('utf8');
|
|
33
|
-
return decrypted;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static encryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
40
|
-
let encryptedRequest;
|
|
41
|
-
try {
|
|
42
|
-
let cipher = CryptoJS.AES.encrypt(data, Datakey, {
|
|
43
|
-
iv: Dataiv,
|
|
44
|
-
mode: CryptoJS.mode.CBC,
|
|
45
|
-
});
|
|
46
|
-
encryptedRequest = cipher.toString();
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.log(error);
|
|
49
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
50
|
-
}
|
|
51
|
-
return encryptedRequest;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static decryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
55
|
-
let decryptRequest;
|
|
56
|
-
try {
|
|
57
|
-
let cipher = CryptoJS.AES.decrypt(data, Datakey, {
|
|
58
|
-
iv: Dataiv,
|
|
59
|
-
mode: CryptoJS.mode.CBC,
|
|
60
|
-
});
|
|
61
|
-
decryptRequest = cipher.toString(CryptoJS.enc.Utf8);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
64
|
-
}
|
|
65
|
-
return decryptRequest;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static encryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
69
|
-
try {
|
|
70
|
-
switch (type) {
|
|
71
|
-
case 'GCM':
|
|
72
|
-
return this.encryptGCM(data, Datakey, Dataiv);
|
|
73
|
-
case 'CBC':
|
|
74
|
-
return this.encryptCBC(data, Datakey, Dataiv);
|
|
75
|
-
default:
|
|
76
|
-
return this.encryptCBC(data, Datakey, Dataiv);
|
|
77
|
-
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static decryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
84
|
-
try {
|
|
85
|
-
switch (type) {
|
|
86
|
-
case 'GCM':
|
|
87
|
-
return this.decryptGCM(data, Datakey, Dataiv);
|
|
88
|
-
case 'CBC':
|
|
89
|
-
return this.decryptCBC(data, Datakey, Dataiv);
|
|
90
|
-
default:
|
|
91
|
-
return this.decryptCBC(data, Datakey, Dataiv);
|
|
92
|
-
}
|
|
93
|
-
} catch (error) {
|
|
94
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
1
|
+
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
|
|
4
|
+
const CryptoJS = require('crypto-js');
|
|
5
|
+
const encryptionType = 'aes-256-cbc';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class EncryptUtilService {
|
|
9
|
+
constructor() {}
|
|
10
|
+
|
|
11
|
+
static encryptGCM(data: any, Datakey: string, Dataiv: string) {
|
|
12
|
+
try {
|
|
13
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
14
|
+
let encrypted = Buffer.concat([
|
|
15
|
+
cipher.update(data, 'utf8'),
|
|
16
|
+
cipher.final(),
|
|
17
|
+
]);
|
|
18
|
+
const tag = cipher.getAuthTag();
|
|
19
|
+
return Buffer.concat([encrypted, tag]).toString('base64');
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static decryptGCM(data: any, Datakey: any, Dataiv: any) {
|
|
26
|
+
try {
|
|
27
|
+
data = Buffer.from(data, 'base64');
|
|
28
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
29
|
+
const tag = data.slice(data.length - 16);
|
|
30
|
+
decipher.setAuthTag(tag);
|
|
31
|
+
data = data.slice(0, data.length - 16);
|
|
32
|
+
let decrypted = decipher.update(data, 'utf8') + decipher.final('utf8');
|
|
33
|
+
return decrypted;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static encryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
40
|
+
let encryptedRequest;
|
|
41
|
+
try {
|
|
42
|
+
let cipher = CryptoJS.AES.encrypt(data, Datakey, {
|
|
43
|
+
iv: Dataiv,
|
|
44
|
+
mode: CryptoJS.mode.CBC,
|
|
45
|
+
});
|
|
46
|
+
encryptedRequest = cipher.toString();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.log(error);
|
|
49
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
50
|
+
}
|
|
51
|
+
return encryptedRequest;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static decryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
55
|
+
let decryptRequest;
|
|
56
|
+
try {
|
|
57
|
+
let cipher = CryptoJS.AES.decrypt(data, Datakey, {
|
|
58
|
+
iv: Dataiv,
|
|
59
|
+
mode: CryptoJS.mode.CBC,
|
|
60
|
+
});
|
|
61
|
+
decryptRequest = cipher.toString(CryptoJS.enc.Utf8);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
64
|
+
}
|
|
65
|
+
return decryptRequest;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static encryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
69
|
+
try {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case 'GCM':
|
|
72
|
+
return this.encryptGCM(data, Datakey, Dataiv);
|
|
73
|
+
case 'CBC':
|
|
74
|
+
return this.encryptCBC(data, Datakey, Dataiv);
|
|
75
|
+
default:
|
|
76
|
+
return this.encryptCBC(data, Datakey, Dataiv);
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static decryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
84
|
+
try {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'GCM':
|
|
87
|
+
return this.decryptGCM(data, Datakey, Dataiv);
|
|
88
|
+
case 'CBC':
|
|
89
|
+
return this.decryptCBC(data, Datakey, Dataiv);
|
|
90
|
+
default:
|
|
91
|
+
return this.decryptCBC(data, Datakey, Dataiv);
|
|
92
|
+
}
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as xlsx from 'xlsx';
|
|
2
|
-
|
|
3
|
-
export class ExcelUtil {
|
|
4
|
-
static readExcel(fileBuffer: Buffer): Record<string, any[]> {
|
|
5
|
-
const workbook = xlsx.read(fileBuffer, { type: 'buffer' });
|
|
6
|
-
const data: Record<string, any[]> = {};
|
|
7
|
-
|
|
8
|
-
workbook.SheetNames.forEach((sheetName) => {
|
|
9
|
-
const sheet = workbook.Sheets[sheetName];
|
|
10
|
-
data[sheetName] = xlsx.utils.sheet_to_json(sheet);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import * as xlsx from 'xlsx';
|
|
2
|
+
|
|
3
|
+
export class ExcelUtil {
|
|
4
|
+
static readExcel(fileBuffer: Buffer): Record<string, any[]> {
|
|
5
|
+
const workbook = xlsx.read(fileBuffer, { type: 'buffer' });
|
|
6
|
+
const data: Record<string, any[]> = {};
|
|
7
|
+
|
|
8
|
+
workbook.SheetNames.forEach((sheetName) => {
|
|
9
|
+
const sheet = workbook.Sheets[sheetName];
|
|
10
|
+
data[sheetName] = xlsx.utils.sheet_to_json(sheet);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
}
|