rez_core 0.0.7 → 1.0.2-o
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/data/master.xlsx +0 -0
- package/dist/app.module.d.ts +0 -2
- package/dist/app.module.js +0 -31
- package/dist/app.module.js.map +1 -1
- package/dist/config/config.module.js +1 -1
- package/dist/config/config.module.js.map +1 -1
- 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/core.module.js +6 -0
- package/dist/core.module.js.map +1 -1
- package/dist/decorators/roles.decorator.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/enterprise/enterprise.module.js +1 -1
- package/dist/module/enterprise/enterprise.module.js.map +1 -1
- package/dist/module/enterprise/service/organization.service.d.ts +9 -7
- package/dist/module/enterprise/service/organization.service.js +35 -14
- package/dist/module/enterprise/service/organization.service.js.map +1 -1
- package/dist/module/layout/controller/layout.controller.d.ts +11 -0
- package/dist/module/layout/controller/layout.controller.js +61 -0
- package/dist/module/layout/controller/layout.controller.js.map +1 -0
- package/dist/module/layout/dto/header.dto.d.ts +0 -0
- package/dist/module/layout/dto/header.dto.js +1 -0
- package/dist/module/layout/dto/header.dto.js.map +1 -0
- package/dist/module/layout/entity/header-items.entity.d.ts +10 -0
- package/dist/module/layout/entity/header-items.entity.js +52 -0
- package/dist/module/layout/entity/header-items.entity.js.map +1 -0
- package/dist/module/layout/entity/header-section.entity.d.ts +7 -0
- package/dist/module/layout/entity/header-section.entity.js +40 -0
- package/dist/module/layout/entity/header-section.entity.js.map +1 -0
- package/dist/module/layout/layout.module.d.ts +2 -0
- package/dist/module/layout/layout.module.js +30 -0
- package/dist/module/layout/layout.module.js.map +1 -0
- package/dist/module/layout/repository/header-items.repository.d.ts +7 -0
- package/dist/module/layout/repository/header-items.repository.js +36 -0
- package/dist/module/layout/repository/header-items.repository.js.map +1 -0
- package/dist/module/layout/repository/header-section.repository.d.ts +7 -0
- package/dist/module/layout/repository/header-section.repository.js +36 -0
- package/dist/module/layout/repository/header-section.repository.js.map +1 -0
- package/dist/module/layout/service/header-section.service.d.ts +8 -0
- package/dist/module/layout/service/header-section.service.js +37 -0
- package/dist/module/layout/service/header-section.service.js.map +1 -0
- package/dist/module/meta/controller/entity.controller.d.ts +1 -0
- package/dist/module/meta/controller/entity.controller.js +37 -1
- package/dist/module/meta/controller/entity.controller.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/entity-table-column.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-table.entity.d.ts +1 -0
- package/dist/module/meta/entity/entity-table.entity.js +4 -0
- package/dist/module/meta/entity/entity-table.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 +15 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/entity-table-column.repository.js +2 -2
- package/dist/module/meta/repository/entity-table.repository.d.ts +1 -0
- package/dist/module/meta/repository/entity-table.repository.js +9 -0
- package/dist/module/meta/repository/entity-table.repository.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 +3 -1
- package/dist/module/meta/service/entity-list.service.js +26 -3
- package/dist/module/meta/service/entity-list.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +13 -5
- package/dist/module/meta/service/entity-service-impl.service.js +92 -15
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table-column.service.d.ts +1 -0
- package/dist/module/meta/service/entity-table-column.service.js +4 -0
- package/dist/module/meta/service/entity-table-column.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +1 -0
- package/dist/module/meta/service/entity-table.service.js +3 -0
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/entity.service.d.ts +3 -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/meta/service/preference.service.d.ts +1 -5
- package/dist/module/meta/service/preference.service.js +3 -11
- package/dist/module/meta/service/preference.service.js.map +1 -1
- 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/module/module.module.js +2 -2
- package/dist/module/module/module.module.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +3 -3
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.js +31 -20
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/menu.service.js +2 -2
- package/dist/module/module/service/menu.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +17 -0
- package/dist/module/notification/controller/otp.controller.js +67 -0
- package/dist/module/notification/controller/otp.controller.js.map +1 -0
- package/dist/module/notification/entity/otp.entity.d.ts +10 -0
- package/dist/module/notification/entity/otp.entity.js +52 -0
- package/dist/module/notification/entity/otp.entity.js.map +1 -0
- package/dist/module/notification/notification.module.d.ts +2 -0
- package/dist/module/notification/notification.module.js +27 -0
- package/dist/module/notification/notification.module.js.map +1 -0
- package/dist/module/notification/repository/otp.repository.d.ts +9 -0
- package/dist/module/notification/repository/otp.repository.js +44 -0
- package/dist/module/notification/repository/otp.repository.js.map +1 -0
- package/dist/module/notification/service/otp.service.d.ts +16 -0
- package/dist/module/notification/service/otp.service.js +66 -0
- package/dist/module/notification/service/otp.service.js.map +1 -0
- package/dist/module/user/controller/login.controller.d.ts +1 -3
- package/dist/module/user/controller/login.controller.js +0 -1
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/dto/create-user.dto.js.map +1 -1
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/repository/user-role-mapping.repository.js +4 -1
- package/dist/module/user/repository/user-role-mapping.repository.js.map +1 -1
- package/dist/module/user/repository/user.repository.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +12 -4
- package/dist/module/user/service/login.service.js +24 -9
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +1 -5
- package/dist/module/user/service/role.service.js +3 -10
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +1 -3
- package/dist/module/user/service/user-session.service.js +1 -1
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +7 -8
- package/dist/module/user/service/user.service.js +13 -17
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +1 -0
- package/dist/module/user/user.module.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/dist/utils/dto/excel-data.dto.d.ts +7 -0
- package/dist/utils/dto/excel-data.dto.js +16 -0
- package/dist/utils/dto/excel-data.dto.js.map +1 -0
- package/dist/utils/dto/excelsheet-data.dto.d.ts +5 -0
- package/dist/utils/dto/excelsheet-data.dto.js +3 -0
- package/dist/utils/dto/excelsheet-data.dto.js.map +1 -0
- package/dist/utils/service/excel-helper.service.d.ts +3 -1
- package/dist/utils/service/excel-helper.service.js +12 -3
- package/dist/utils/service/excel-helper.service.js.map +1 -1
- package/dist/utils/service/loggingUtil.service.js +6 -6
- package/dist/utils/service/loggingUtil.service.js.map +1 -1
- package/dist/utils/utils.module.js.map +1 -1
- package/nest-cli.json +6 -0
- package/package.json +1 -1
- package/src/app.module.ts +0 -0
- package/src/config/config.module.ts +1 -1
- package/src/config/database.config.ts +10 -5
- package/src/constant/global.constant.ts +13 -4
- package/src/core.module.ts +6 -0
- package/src/decorators/roles.decorator.ts +5 -2
- package/src/module/auth/auth.module.ts +3 -2
- package/src/module/auth/guards/google-auth.guard.ts +1 -1
- 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/enterprise.module.ts +2 -3
- package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
- package/src/module/enterprise/entity/organization.entity.ts +80 -80
- package/src/module/enterprise/service/organization.service.ts +48 -13
- package/src/module/layout/controller/layout.controller.ts +32 -0
- package/src/module/layout/dto/header.dto.ts +0 -0
- package/src/module/layout/entity/header-items.entity.ts +28 -0
- package/src/module/layout/entity/header-section.entity.ts +19 -0
- package/src/module/layout/layout.module.ts +17 -0
- package/src/module/layout/repository/header-items.repository.ts +18 -0
- package/src/module/layout/repository/header-section.repository.ts +18 -0
- package/src/module/layout/service/header-section.service.ts +26 -0
- package/src/module/master/controller/master.controller.ts +22 -22
- package/src/module/meta/controller/entity.controller.ts +56 -3
- 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 +2 -3
- package/src/module/meta/entity/entity-master.entity.ts +3 -0
- package/src/module/meta/entity/entity-table-column.entity.ts +1 -1
- package/src/module/meta/entity/entity-table.entity.ts +4 -2
- 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 +15 -1
- package/src/module/meta/repository/attribute-master.repository.ts +28 -28
- package/src/module/meta/repository/entity-table-column.repository.ts +3 -3
- package/src/module/meta/repository/entity-table.repository.ts +14 -0
- 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 +36 -7
- package/src/module/meta/service/entity-service-impl.service.ts +138 -20
- package/src/module/meta/service/entity-table-column.service.ts +14 -1
- package/src/module/meta/service/entity-table.service.ts +8 -1
- package/src/module/meta/service/entity.service.ts +13 -1
- package/src/module/meta/service/media-data.service.ts +44 -0
- package/src/module/meta/service/preference.service.ts +2 -17
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/controller/module-access.controller.ts +1 -1
- package/src/module/module/entity/menu.entity.ts +10 -11
- 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 +9 -10
- package/src/module/module/module.module.ts +2 -4
- package/src/module/module/repository/menu.repository.ts +7 -10
- package/src/module/module/repository/module-access.repository.ts +57 -42
- package/src/module/module/service/menu.service.ts +9 -10
- package/src/module/module/service/module-access.service.ts +8 -3
- package/src/module/notification/controller/otp.controller.ts +41 -0
- package/src/module/notification/entity/otp.entity.ts +28 -0
- package/src/module/notification/notification.module.ts +14 -0
- package/src/module/notification/repository/otp.repository.ts +27 -0
- package/src/module/notification/service/otp.service.ts +56 -0
- package/src/module/user/controller/login.controller.ts +2 -1
- package/src/module/user/controller/user.controller.ts +28 -28
- package/src/module/user/dto/create-user.dto.ts +43 -43
- package/src/module/user/dto/update-user.dto.ts +4 -4
- package/src/module/user/entity/role.entity.ts +1 -1
- 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/user-role-mapping.repository.ts +9 -3
- package/src/module/user/repository/user.repository.ts +2 -2
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/module/user/service/login.service.ts +25 -8
- package/src/module/user/service/role.service.ts +2 -13
- package/src/module/user/service/user-role-mapping.service.ts +1 -1
- package/src/module/user/service/user-session.service.ts +2 -2
- package/src/module/user/service/user.service.ts +16 -27
- package/src/module/user/user.module.ts +1 -1
- 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/dto/excel-data.dto.ts +14 -0
- package/src/utils/dto/excelsheet-data.dto.ts +5 -0
- package/src/utils/service/clockIDGenUtil.service.ts +1 -1
- package/src/utils/service/dateUtil.service.ts +1 -1
- package/src/utils/service/encryptUtil.service.ts +97 -97
- package/src/utils/service/excel-helper.service.ts +14 -1
- package/src/utils/service/excelUtil.service.ts +15 -15
- package/src/utils/service/loggingUtil.service.ts +48 -48
- package/src/utils/service/reflection-helper.service.ts +53 -53
- package/src/utils/utils.module.ts +7 -7
- package/.env +0 -6
- 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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExcelData = void 0;
|
|
4
|
+
class ExcelData {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.sheetList = [];
|
|
7
|
+
}
|
|
8
|
+
addSheet(sheetData) {
|
|
9
|
+
this.sheetList.push(sheetData);
|
|
10
|
+
}
|
|
11
|
+
addSheetAt(sheetData, position) {
|
|
12
|
+
this.sheetList.splice(position, 0, sheetData);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ExcelData = ExcelData;
|
|
16
|
+
//# sourceMappingURL=excel-data.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"excel-data.dto.js","sourceRoot":"","sources":["../../../src/utils/dto/excel-data.dto.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IAAtB;QAEE,cAAS,GAAqB,EAAE,CAAC;IASnC,CAAC;IAPC,QAAQ,CAAC,SAAyB;QAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,SAAyB,EAAE,QAAgB;QACpD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;CACF;AAXD,8BAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"excelsheet-data.dto.js","sourceRoot":"","sources":["../../../src/utils/dto/excelsheet-data.dto.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { ExcelData } from '../dto/excel-data.dto';
|
|
2
|
+
export declare class ExcelHelper {
|
|
2
3
|
static getHeader(filePath: string, sheetName: string): string[];
|
|
3
4
|
static readExcel(filePath: string, rowLevel: string, sheetName: string): string[][];
|
|
4
5
|
static getRowData(filePath: string, sheetName: string): string[][];
|
|
5
6
|
static getJSONStringFromList(header: string[], rowData: string[][]): string;
|
|
6
7
|
static getDataObjectListFromXLS<T>(filePath: string, sheetName: string, classType: new () => T): T[];
|
|
8
|
+
static writeExcel(excelData: ExcelData): void;
|
|
7
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ExcelHelper = void 0;
|
|
4
4
|
const ExcelJS = require("exceljs");
|
|
5
|
-
|
|
5
|
+
const XLSX = require("xlsx");
|
|
6
|
+
class ExcelHelper {
|
|
6
7
|
static getHeader(filePath, sheetName) {
|
|
7
8
|
const rows = this.readExcel(filePath, 'HEADER', sheetName);
|
|
8
9
|
return rows.length > 0 ? rows[0] : [];
|
|
@@ -39,6 +40,14 @@ class ExcelHelperService {
|
|
|
39
40
|
const jsonString = this.getJSONStringFromList(header, rowData);
|
|
40
41
|
return JSON.parse(jsonString);
|
|
41
42
|
}
|
|
43
|
+
static writeExcel(excelData) {
|
|
44
|
+
const wb = XLSX.utils.book_new();
|
|
45
|
+
for (const sheetData of excelData.sheetList) {
|
|
46
|
+
const ws = XLSX.utils.aoa_to_sheet([sheetData.headers, ...sheetData.rowList]);
|
|
47
|
+
XLSX.utils.book_append_sheet(wb, ws, sheetData.sheetName || 'Sheet1');
|
|
48
|
+
}
|
|
49
|
+
XLSX.writeFile(wb, excelData.filePath);
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
|
-
exports.
|
|
52
|
+
exports.ExcelHelper = ExcelHelper;
|
|
44
53
|
//# sourceMappingURL=excel-helper.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"excel-helper.service.js","sourceRoot":"","sources":["../../../src/utils/service/excel-helper.service.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC,MAAa,
|
|
1
|
+
{"version":3,"file":"excel-helper.service.js","sourceRoot":"","sources":["../../../src/utils/service/excel-helper.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -20,21 +20,21 @@ let LoggingService = class LoggingService {
|
|
|
20
20
|
let levelInfo = level.toLowerCase().trim();
|
|
21
21
|
let logger = new common_1.Logger(serviceName);
|
|
22
22
|
const fileConfiguration = {
|
|
23
|
-
format: winston.format.combine(winston.format.errors({ stzack: true }), winston.format.timestamp({ format: 'DD/MM/YYYY HH:mm:ss' }), winston.format.printf(info => `${info.timestamp} : ${info.level}: ${serviceName}: ${methodName} : ${message} : ${JSON.stringify(parameters) ||
|
|
23
|
+
format: winston.format.combine(winston.format.errors({ stzack: true }), winston.format.timestamp({ format: 'DD/MM/YYYY HH:mm:ss' }), winston.format.printf((info) => `${info.timestamp} : ${info.level}: ${serviceName}: ${methodName} : ${message} : ${JSON.stringify(parameters) || ''} : ${JSON.stringify(debuginfo) || ''}`)),
|
|
24
24
|
transports: [
|
|
25
25
|
new winston_1.transports.File({
|
|
26
|
-
dirname: `/data01/logs/${moment().format(
|
|
26
|
+
dirname: `/data01/logs/${moment().format('DD-MM-YYYY')}/activity/${moment().format('HH dddd')}`,
|
|
27
27
|
filename: 'activity.log',
|
|
28
|
-
level: `${level}
|
|
29
|
-
})
|
|
28
|
+
level: `${level}`,
|
|
29
|
+
}),
|
|
30
30
|
],
|
|
31
31
|
};
|
|
32
32
|
const filelogger = winston.createLogger(fileConfiguration);
|
|
33
33
|
let data = `${message} -- Parameters: ${JSON.stringify(parameters)}`;
|
|
34
|
-
if (levelInfo ==
|
|
34
|
+
if (levelInfo == 'debug' || levelInfo == 'info') {
|
|
35
35
|
logger.debug(`${methodName} : ${message} : Parameters :${JSON.stringify(parameters)}: Debug Info: ${JSON.stringify(debuginfo)}`);
|
|
36
36
|
}
|
|
37
|
-
else if (levelInfo ==
|
|
37
|
+
else if (levelInfo == 'error') {
|
|
38
38
|
logger.error(`${methodName} : ${message} : Parameters :${JSON.stringify(parameters)}: Debug Info: ${JSON.stringify(debuginfo)}`);
|
|
39
39
|
}
|
|
40
40
|
filelogger.on('finish', () => { });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggingUtil.service.js","sourceRoot":"","sources":["../../../src/utils/service/loggingUtil.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AACpD,qCAAqC;
|
|
1
|
+
{"version":3,"file":"loggingUtil.service.js","sourceRoot":"","sources":["../../../src/utils/service/loggingUtil.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AACpD,qCAAqC;AAErC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAG1B,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,gBAAe,CAAC;IAEhB,KAAK,CAAC,GAAG,CACP,KAAa,EACb,WAAmB,EACnB,UAAkB,EAClB,OAAe,EACf,UAAsB,EACtB,SAAqB;QAErB,IAAI,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,MAAM,GAAG,IAAI,eAAM,CAAC,WAAW,CAAC,CAAC;QAErC,MAAM,iBAAiB,GAAG;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EACvC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,EAC3D,OAAO,CAAC,MAAM,CAAC,MAAM,CACnB,CAAC,IAAI,EAAE,EAAE,CACP,GAAG,IAAI,CAAC,SAAS,MAAM,IAAI,CAAC,KAAK,KAAK,WAAW,KAAK,UAAU,MAAM,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAC7J,CACF;YAED,UAAU,EAAE;gBACV,IAAI,oBAAU,CAAC,IAAI,CAAC;oBAClB,OAAO,EAAE,gBAAgB,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;oBAC/F,QAAQ,EAAE,cAAc;oBACxB,KAAK,EAAE,GAAG,KAAK,EAAE;iBAClB,CAAC;aACH;SACF,CAAC;QAEF,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,IAAI,GAAG,GAAG,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QAErE,IAAI,SAAS,IAAI,OAAO,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;YAChD,MAAM,CAAC,KAAK,CACV,GAAG,UAAU,MAAM,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CACnH,CAAC;QACJ,CAAC;aAAM,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;YAChC,MAAM,CAAC,KAAK,CACV,GAAG,UAAU,MAAM,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CACnH,CAAC;QACJ,CAAC;QACD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAClC,UAAU,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AAhDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;;GACA,cAAc,CAgD1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.module.js","sourceRoot":"","sources":["../../src/utils/utils.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.module.js","sourceRoot":"","sources":["../../src/utils/utils.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,uEAA+D;AAC/D,mFAAuE;AACvE,mEAAwD;AACxD,6EAAqE;AAO9D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAE,6BAAS,EAAE,0CAAiB,CAAC;QAC3E,OAAO,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAE,6BAAS,EAAE,0CAAiB,CAAC;KAC1E,CAAC;GACW,WAAW,CAAG"}
|
package/nest-cli.json
CHANGED
package/package.json
CHANGED
|
File without changes
|
|
@@ -10,7 +10,7 @@ import { MySqlConfiguration } from './database.config';
|
|
|
10
10
|
TypeOrmModule.forRootAsync({
|
|
11
11
|
useClass: MySqlConfiguration,
|
|
12
12
|
}),
|
|
13
|
-
ConfigModule.forRoot({isGlobal: true})
|
|
13
|
+
ConfigModule.forRoot({ isGlobal: true }),
|
|
14
14
|
],
|
|
15
15
|
// providers: [MySqlConfiguration],
|
|
16
16
|
exports: [TypeOrmModule],
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
3
|
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm';
|
|
3
4
|
|
|
4
5
|
@Injectable()
|
|
5
6
|
export class MySqlConfiguration implements TypeOrmOptionsFactory {
|
|
6
7
|
|
|
8
|
+
constructor(
|
|
9
|
+
private configService: ConfigService,
|
|
10
|
+
){}
|
|
11
|
+
|
|
7
12
|
createTypeOrmOptions(): TypeOrmModuleOptions {
|
|
8
13
|
return {
|
|
9
14
|
type: 'mysql',
|
|
10
|
-
host:
|
|
11
|
-
port: parseInt(
|
|
12
|
-
username:
|
|
13
|
-
password:
|
|
14
|
-
database:
|
|
15
|
+
host: this.configService.get('DB_HOST')|| '13.234.25.234',
|
|
16
|
+
port: parseInt(this.configService.get('DB_PORT') || '3306', 10),
|
|
17
|
+
username: this.configService.get('DB_USER') || 'root',
|
|
18
|
+
password: this.configService.get('DB_PASS') || 'Rezolut@123',
|
|
19
|
+
database: this.configService.get('DB_NAME') || 'core',
|
|
15
20
|
entities: [__dirname + '/../module/**/*.entity.{ts,js}'],
|
|
16
21
|
synchronize: true,
|
|
17
22
|
autoLoadEntities: true,
|
|
@@ -4,7 +4,16 @@ export const ENTITYTYPE_ENTITYMASTER = 'EMS';
|
|
|
4
4
|
export const ENTITYTYPE_ROLE = 'ROL';
|
|
5
5
|
export const ENTITYTYPE_ENTITYTABLE = 'ETB';
|
|
6
6
|
export const ENTITYTYPE_ENTITYTABLECOLUMN = 'ETC';
|
|
7
|
-
export const ENTITYTYPE_PREFERENCEMASTER = 'PRM'
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
|
|
7
|
+
export const ENTITYTYPE_PREFERENCEMASTER = 'PRM';
|
|
8
|
+
export const ENTITYTYPE_VIEWMASTER = 'VMS';
|
|
9
|
+
export const ENTITYTYPE_MEDIA = 'MDA';
|
|
10
|
+
|
|
11
|
+
export const STORAGETYPE_SINGLEJSON = 'singlejson';
|
|
12
|
+
export const STORAGETYPE_COLUMN = 'column';
|
|
13
|
+
|
|
14
|
+
// SECRET KEY
|
|
15
|
+
export const secretKey: string = process.env.secret_key || '';
|
|
16
|
+
|
|
17
|
+
// STATUS
|
|
18
|
+
export const STATUS_ACTIVE = 'ACTIVE';
|
|
19
|
+
export const STATUS_INACTIVE = 'INACTIVE';
|
package/src/core.module.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { UtilsModule } from './utils/utils.module';
|
|
|
5
5
|
import { UserModule } from './module/user/user.module';
|
|
6
6
|
import { EntityModule } from './module/meta/entity.module';
|
|
7
7
|
import { ModuleModule } from './module/module/module.module';
|
|
8
|
+
import { NotificationModule } from './module/notification/notification.module';
|
|
9
|
+
import { LayoutModule } from './module/layout/layout.module';
|
|
8
10
|
|
|
9
11
|
@Global()
|
|
10
12
|
@Module({})
|
|
@@ -24,6 +26,8 @@ export class CoreModule {
|
|
|
24
26
|
UtilsModule,
|
|
25
27
|
UserModule,
|
|
26
28
|
ModuleModule,
|
|
29
|
+
NotificationModule,
|
|
30
|
+
LayoutModule,
|
|
27
31
|
],
|
|
28
32
|
exports: [
|
|
29
33
|
ConfigModule,
|
|
@@ -33,6 +37,8 @@ export class CoreModule {
|
|
|
33
37
|
UtilsModule,
|
|
34
38
|
UserModule,
|
|
35
39
|
ModuleModule,
|
|
40
|
+
NotificationModule,
|
|
41
|
+
LayoutModule,
|
|
36
42
|
],
|
|
37
43
|
};
|
|
38
44
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {applyDecorators, SetMetadata} from
|
|
1
|
+
import { applyDecorators, SetMetadata } from '@nestjs/common';
|
|
2
2
|
|
|
3
3
|
export const Roles = (moduleCode: string, actions: string) =>
|
|
4
|
-
|
|
4
|
+
applyDecorators(
|
|
5
|
+
SetMetadata('moduleCode', moduleCode),
|
|
6
|
+
SetMetadata('actions', actions),
|
|
7
|
+
);
|
|
@@ -5,6 +5,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
5
5
|
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
6
6
|
import { JwtAuthService } from './services/jwt.service';
|
|
7
7
|
import { JwtAuthGuard } from './guards/jwt.guard';
|
|
8
|
+
import { secretKey } from '../../constant/global.constant';
|
|
8
9
|
import { PassportModule } from '@nestjs/passport';
|
|
9
10
|
import { UserSession } from '../user/entity/user-session.entity';
|
|
10
11
|
import { GoogleStrategy } from './strategies/google.strategy';
|
|
@@ -15,10 +16,10 @@ import { RolesGuard } from './guards/role.guard';
|
|
|
15
16
|
ConfigModule, // ✅ Ensure ConfigModule is imported
|
|
16
17
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
17
18
|
JwtModule.registerAsync({
|
|
18
|
-
imports: [ConfigModule],
|
|
19
|
+
imports: [ConfigModule],
|
|
19
20
|
inject: [ConfigService],
|
|
20
21
|
useFactory: async (configService: ConfigService) => ({
|
|
21
|
-
secret:
|
|
22
|
+
secret: configService.get('SECRET_KEY'),
|
|
22
23
|
signOptions: { expiresIn: '1800s' },
|
|
23
24
|
}),
|
|
24
25
|
}),
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ExecutionContext, Injectable } from '@nestjs/common';
|
|
2
|
-
import { AuthGuard } from '@nestjs/passport';
|
|
3
|
-
import { Reflector } from '@nestjs/core';
|
|
4
|
-
import { Observable } from 'rxjs';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class JwtAuthGuard extends AuthGuard('jwt') {
|
|
8
|
-
constructor(private reflector: Reflector) {
|
|
9
|
-
super();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
canActivate(
|
|
13
|
-
context: ExecutionContext,
|
|
14
|
-
): Promise<boolean> | boolean | Observable<boolean> {
|
|
15
|
-
const isPublic = this.reflector.getAllAndOverride('isPublic', [
|
|
16
|
-
context.getHandler(),
|
|
17
|
-
context.getClass(),
|
|
18
|
-
]);
|
|
19
|
-
if (isPublic) return true;
|
|
20
|
-
return super.canActivate(context);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
import { ExecutionContext, Injectable } from '@nestjs/common';
|
|
2
|
+
import { AuthGuard } from '@nestjs/passport';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class JwtAuthGuard extends AuthGuard('jwt') {
|
|
8
|
+
constructor(private reflector: Reflector) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
canActivate(
|
|
13
|
+
context: ExecutionContext,
|
|
14
|
+
): Promise<boolean> | boolean | Observable<boolean> {
|
|
15
|
+
const isPublic = this.reflector.getAllAndOverride('isPublic', [
|
|
16
|
+
context.getHandler(),
|
|
17
|
+
context.getClass(),
|
|
18
|
+
]);
|
|
19
|
+
if (isPublic) return true;
|
|
20
|
+
return super.canActivate(context);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CanActivate,
|
|
3
|
-
ExecutionContext,
|
|
4
|
-
ForbiddenException,
|
|
5
|
-
Injectable,
|
|
6
|
-
UnauthorizedException,
|
|
7
|
-
} from '@nestjs/common';
|
|
8
|
-
import { Reflector } from '@nestjs/core';
|
|
9
|
-
import { UserData } from '../../user/entity/user.entity';
|
|
10
|
-
import { InjectEntityManager } from '@nestjs/typeorm';
|
|
11
|
-
import { EntityManager } from 'typeorm';
|
|
12
|
-
|
|
13
|
-
@Injectable()
|
|
14
|
-
export class RolesGuard implements CanActivate {
|
|
15
|
-
constructor(
|
|
16
|
-
private reflector: Reflector,
|
|
17
|
-
@InjectEntityManager() private entityManager: EntityManager,
|
|
18
|
-
) {}
|
|
19
|
-
|
|
20
|
-
async canActivate(context: ExecutionContext) {
|
|
21
|
-
const request = context
|
|
22
|
-
.switchToHttp()
|
|
23
|
-
.getRequest<Request & { user: any }>();
|
|
24
|
-
const object = request.user;
|
|
25
|
-
|
|
26
|
-
const users: UserData = await this.entityManager.query(
|
|
27
|
-
`SELECT * FROM cr_user WHERE id = ${object.userId} LIMIT 1`,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const user = users[0];
|
|
31
|
-
if (!user || !user['role_id']) {
|
|
32
|
-
throw new UnauthorizedException('User not authorized');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const requiredModule = this.reflector.get<string>(
|
|
36
|
-
'moduleCode',
|
|
37
|
-
context.getHandler(),
|
|
38
|
-
);
|
|
39
|
-
const requiredActions = this.reflector.get<string>(
|
|
40
|
-
'actions',
|
|
41
|
-
context.getHandler(),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const roleAccess = await this.entityManager.query(
|
|
45
|
-
`SELECT *
|
|
46
|
-
FROM cr_module_access
|
|
47
|
-
WHERE role_id = ${user['role_id']}
|
|
48
|
-
AND module_code = '${requiredModule}'`,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
if (!roleAccess || roleAccess.length === 0) {
|
|
52
|
-
throw new ForbiddenException(
|
|
53
|
-
'Access denied: No permissions found for this module',
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const hasAccess = roleAccess.some(
|
|
58
|
-
(access) =>
|
|
59
|
-
requiredActions.includes(access.action_type) &&
|
|
60
|
-
access.access_flag === 1,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
if (!hasAccess) {
|
|
64
|
-
throw new ForbiddenException('Access denied: Insufficient permissions.');
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
CanActivate,
|
|
3
|
+
ExecutionContext,
|
|
4
|
+
ForbiddenException,
|
|
5
|
+
Injectable,
|
|
6
|
+
UnauthorizedException,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { Reflector } from '@nestjs/core';
|
|
9
|
+
import { UserData } from '../../user/entity/user.entity';
|
|
10
|
+
import { InjectEntityManager } from '@nestjs/typeorm';
|
|
11
|
+
import { EntityManager } from 'typeorm';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class RolesGuard implements CanActivate {
|
|
15
|
+
constructor(
|
|
16
|
+
private reflector: Reflector,
|
|
17
|
+
@InjectEntityManager() private entityManager: EntityManager,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
async canActivate(context: ExecutionContext) {
|
|
21
|
+
const request = context
|
|
22
|
+
.switchToHttp()
|
|
23
|
+
.getRequest<Request & { user: any }>();
|
|
24
|
+
const object = request.user;
|
|
25
|
+
|
|
26
|
+
const users: UserData = await this.entityManager.query(
|
|
27
|
+
`SELECT * FROM cr_user WHERE id = ${object.userId} LIMIT 1`,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const user = users[0];
|
|
31
|
+
if (!user || !user['role_id']) {
|
|
32
|
+
throw new UnauthorizedException('User not authorized');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const requiredModule = this.reflector.get<string>(
|
|
36
|
+
'moduleCode',
|
|
37
|
+
context.getHandler(),
|
|
38
|
+
);
|
|
39
|
+
const requiredActions = this.reflector.get<string>(
|
|
40
|
+
'actions',
|
|
41
|
+
context.getHandler(),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const roleAccess = await this.entityManager.query(
|
|
45
|
+
`SELECT *
|
|
46
|
+
FROM cr_module_access
|
|
47
|
+
WHERE role_id = ${user['role_id']}
|
|
48
|
+
AND module_code = '${requiredModule}'`,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (!roleAccess || roleAccess.length === 0) {
|
|
52
|
+
throw new ForbiddenException(
|
|
53
|
+
'Access denied: No permissions found for this module',
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const hasAccess = roleAccess.some(
|
|
58
|
+
(access) =>
|
|
59
|
+
requiredActions.includes(access.action_type) &&
|
|
60
|
+
access.access_flag === 1,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!hasAccess) {
|
|
64
|
+
throw new ForbiddenException('Access denied: Insufficient permissions.');
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
-
import { UserService } from '../../user/service/user.service';
|
|
3
|
-
import { JwtService } from '@nestjs/jwt';
|
|
4
|
-
import { UserData } from '../../user/entity/user.entity';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class AuthService {
|
|
8
|
-
constructor(
|
|
9
|
-
private userService: UserService,
|
|
10
|
-
private jwtService: JwtService,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async validateUser(email: string, password: string): Promise<UserData> {
|
|
14
|
-
const user = await this.userService.findByEmailId(email);
|
|
15
|
-
if (!user) {
|
|
16
|
-
throw new BadRequestException('User not found');
|
|
17
|
-
}
|
|
18
|
-
const isMatch: boolean = password === user.password;
|
|
19
|
-
if (!isMatch) {
|
|
20
|
-
throw new BadRequestException('Password does not match');
|
|
21
|
-
}
|
|
22
|
-
return user;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async login(user: UserData) {
|
|
26
|
-
const payload = { email: user.email_id, id: user.id };
|
|
27
|
-
return { access_token: this.jwtService.sign(payload) };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
+
import { UserService } from '../../user/service/user.service';
|
|
3
|
+
import { JwtService } from '@nestjs/jwt';
|
|
4
|
+
import { UserData } from '../../user/entity/user.entity';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class AuthService {
|
|
8
|
+
constructor(
|
|
9
|
+
private userService: UserService,
|
|
10
|
+
private jwtService: JwtService,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async validateUser(email: string, password: string): Promise<UserData> {
|
|
14
|
+
const user = await this.userService.findByEmailId(email);
|
|
15
|
+
if (!user) {
|
|
16
|
+
throw new BadRequestException('User not found');
|
|
17
|
+
}
|
|
18
|
+
const isMatch: boolean = password === user.password;
|
|
19
|
+
if (!isMatch) {
|
|
20
|
+
throw new BadRequestException('Password does not match');
|
|
21
|
+
}
|
|
22
|
+
return user;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async login(user: UserData) {
|
|
26
|
+
const payload = { email: user.email_id, id: user.id };
|
|
27
|
+
return { access_token: this.jwtService.sign(payload) };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { JwtService } from '@nestjs/jwt';
|
|
3
|
-
|
|
4
|
-
@Injectable()
|
|
5
|
-
export class JwtAuthService {
|
|
6
|
-
constructor(private readonly jwtService: JwtService) {}
|
|
7
|
-
|
|
8
|
-
generateJwt(payload: any): string {
|
|
9
|
-
return this.jwtService.sign(payload);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { JwtService } from '@nestjs/jwt';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class JwtAuthService {
|
|
6
|
+
constructor(private readonly jwtService: JwtService) {}
|
|
7
|
+
|
|
8
|
+
generateJwt(payload: any): string {
|
|
9
|
+
return this.jwtService.sign(payload);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
3
|
import { PassportStrategy } from '@nestjs/passport';
|
|
3
4
|
import { Strategy, VerifyCallback } from 'passport-google-oauth20';
|
|
4
5
|
|
|
5
6
|
@Injectable()
|
|
6
7
|
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
|
7
|
-
constructor(
|
|
8
|
+
constructor(
|
|
9
|
+
private configService: ConfigService,
|
|
10
|
+
) {
|
|
8
11
|
super({
|
|
9
|
-
clientID:
|
|
10
|
-
clientSecret:
|
|
11
|
-
callbackURL:
|
|
12
|
+
clientID: configService.get('CLIENT_ID'),
|
|
13
|
+
clientSecret: configService.get('CLIENT_SECRET'),
|
|
14
|
+
callbackURL:configService.get('CALLBACK_URL'),
|
|
12
15
|
scope: ['email', 'profile'],
|
|
13
16
|
});
|
|
14
17
|
}
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
|
2
2
|
import { PassportStrategy } from '@nestjs/passport';
|
|
3
3
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
4
|
+
import { secretKey } from '../../../constant/global.constant';
|
|
4
5
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
5
|
-
import {
|
|
6
|
-
import { UserSession } from '../../../module/user/entity/user-session.entity';
|
|
6
|
+
import { UserSession } from 'src/module/user/entity/user-session.entity';
|
|
7
7
|
import { Repository } from 'typeorm';
|
|
8
|
+
import { ConfigService } from '@nestjs/config';
|
|
8
9
|
|
|
9
10
|
@Injectable()
|
|
10
11
|
export class JwtStrategy extends PassportStrategy(Strategy) {
|
|
11
12
|
constructor(
|
|
12
|
-
private readonly configService: ConfigService, // ✅ Inject ConfigService
|
|
13
13
|
@InjectRepository(UserSession)
|
|
14
14
|
private userSessionRepository: Repository<UserSession>,
|
|
15
|
+
private configService: ConfigService,
|
|
15
16
|
) {
|
|
16
17
|
super({
|
|
17
18
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
18
19
|
ignoreExpiration: false,
|
|
19
|
-
secretOrKey:
|
|
20
|
+
secretOrKey:configService.get('SECRET_KEY'),
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
-
console.log('Loaded JWT Secret:', configService.get<string>('secret_key')); // Debugging
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
async validate(payload) {
|