ecrs-auth-core 1.0.0
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/dist/auth.controller.d.ts +9 -0
- package/dist/auth.controller.js +42 -0
- package/dist/auth.module.d.ts +6 -0
- package/dist/auth.module.js +64 -0
- package/dist/auth.service.d.ts +27 -0
- package/dist/auth.service.js +211 -0
- package/dist/decorators/current-user.decorator.d.ts +1 -0
- package/dist/decorators/current-user.decorator.js +9 -0
- package/dist/decorators/feature.decorator.d.ts +1 -0
- package/dist/decorators/feature.decorator.js +11 -0
- package/dist/decorators/has-permission.decorator.d.ts +6 -0
- package/dist/decorators/has-permission.decorator.js +8 -0
- package/dist/decorators/roles.decorator.d.ts +1 -0
- package/dist/decorators/roles.decorator.js +6 -0
- package/dist/decorators/route-permission.decorator.d.ts +1 -0
- package/dist/decorators/route-permission.decorator.js +11 -0
- package/dist/dtos/login.dto.d.ts +4 -0
- package/dist/dtos/login.dto.js +7 -0
- package/dist/entities/feature.entity.d.ts +9 -0
- package/dist/entities/feature.entity.js +48 -0
- package/dist/entities/module-route.entity.d.ts +9 -0
- package/dist/entities/module-route.entity.js +48 -0
- package/dist/entities/module-screen-permission.entity.d.ts +15 -0
- package/dist/entities/module-screen-permission.entity.js +44 -0
- package/dist/entities/module.entity.d.ts +8 -0
- package/dist/entities/module.entity.js +44 -0
- package/dist/entities/role.entity.d.ts +6 -0
- package/dist/entities/role.entity.js +36 -0
- package/dist/entities/user-feature-access.entity.d.ts +19 -0
- package/dist/entities/user-feature-access.entity.js +88 -0
- package/dist/entities/user-module-access.entity.d.ts +12 -0
- package/dist/entities/user-module-access.entity.js +60 -0
- package/dist/entities/user.entity.d.ts +24 -0
- package/dist/entities/user.entity.js +108 -0
- package/dist/guards/feature.guard.d.ts +7 -0
- package/dist/guards/feature.guard.js +34 -0
- package/dist/guards/module.guard.d.ts +8 -0
- package/dist/guards/module.guard.js +36 -0
- package/dist/guards/permission.guard.d.ts +7 -0
- package/dist/guards/permission.guard.js +41 -0
- package/dist/guards/roles.guard.d.ts +7 -0
- package/dist/guards/roles.guard.js +34 -0
- package/dist/guards/route.guard.d.ts +7 -0
- package/dist/guards/route.guard.js +34 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +28 -0
- package/dist/jwt/jwt.guard.d.ts +4 -0
- package/dist/jwt/jwt.guard.js +18 -0
- package/dist/jwt/jwt.strategy.d.ts +14 -0
- package/dist/jwt/jwt.strategy.js +43 -0
- package/package.json +41 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthService } from './auth.service';
|
|
2
|
+
import { LoginDto } from './dtos/login.dto';
|
|
3
|
+
export declare class AuthController {
|
|
4
|
+
private readonly authService;
|
|
5
|
+
constructor(authService: AuthService);
|
|
6
|
+
login(body: LoginDto): Promise<{
|
|
7
|
+
access_token: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthController = void 0;
|
|
16
|
+
// src/auth.controller.ts
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const auth_service_1 = require("./auth.service");
|
|
19
|
+
const login_dto_1 = require("./dtos/login.dto");
|
|
20
|
+
let AuthController = class AuthController {
|
|
21
|
+
constructor(authService) {
|
|
22
|
+
this.authService = authService;
|
|
23
|
+
}
|
|
24
|
+
async login(body) {
|
|
25
|
+
const user = await this.authService.validateUser(body.email, body.password);
|
|
26
|
+
if (!user)
|
|
27
|
+
throw new common_1.UnauthorizedException('Invalid credentials');
|
|
28
|
+
return this.authService.login(user);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.AuthController = AuthController;
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, common_1.Post)('login'),
|
|
34
|
+
__param(0, (0, common_1.Body)()),
|
|
35
|
+
__metadata("design:type", Function),
|
|
36
|
+
__metadata("design:paramtypes", [login_dto_1.LoginDto]),
|
|
37
|
+
__metadata("design:returntype", Promise)
|
|
38
|
+
], AuthController.prototype, "login", null);
|
|
39
|
+
exports.AuthController = AuthController = __decorate([
|
|
40
|
+
(0, common_1.Controller)('auth'),
|
|
41
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
42
|
+
], AuthController);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var AuthCoreModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuthCoreModule = void 0;
|
|
11
|
+
// src/auth.module.ts
|
|
12
|
+
const common_1 = require("@nestjs/common");
|
|
13
|
+
const auth_service_1 = require("./auth.service");
|
|
14
|
+
const jwt_strategy_1 = require("./jwt/jwt.strategy");
|
|
15
|
+
const jwt_guard_1 = require("./jwt/jwt.guard");
|
|
16
|
+
const auth_controller_1 = require("./auth.controller");
|
|
17
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
18
|
+
const module_guard_1 = require("./guards/module.guard");
|
|
19
|
+
const roles_guard_1 = require("./guards/roles.guard");
|
|
20
|
+
const feature_guard_1 = require("./guards/feature.guard");
|
|
21
|
+
const route_guard_1 = require("./guards/route.guard");
|
|
22
|
+
const permission_guard_1 = require("./guards/permission.guard");
|
|
23
|
+
let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
|
|
24
|
+
static register(options) {
|
|
25
|
+
return {
|
|
26
|
+
module: AuthCoreModule_1,
|
|
27
|
+
providers: [
|
|
28
|
+
auth_service_1.AuthService,
|
|
29
|
+
jwt_strategy_1.JwtStrategy,
|
|
30
|
+
jwt_guard_1.JwtAuthGuard,
|
|
31
|
+
module_guard_1.ModuleGuard,
|
|
32
|
+
roles_guard_1.RolesGuard,
|
|
33
|
+
feature_guard_1.FeatureGuard,
|
|
34
|
+
route_guard_1.RouteGuard,
|
|
35
|
+
permission_guard_1.PermissionGuard,
|
|
36
|
+
{
|
|
37
|
+
provide: 'MODULE_CONFIG',
|
|
38
|
+
useValue: options,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
controllers: [auth_controller_1.AuthController],
|
|
42
|
+
exports: [
|
|
43
|
+
auth_service_1.AuthService,
|
|
44
|
+
jwt_guard_1.JwtAuthGuard,
|
|
45
|
+
jwt_strategy_1.JwtStrategy,
|
|
46
|
+
module_guard_1.ModuleGuard,
|
|
47
|
+
roles_guard_1.RolesGuard,
|
|
48
|
+
feature_guard_1.FeatureGuard,
|
|
49
|
+
route_guard_1.RouteGuard,
|
|
50
|
+
permission_guard_1.PermissionGuard
|
|
51
|
+
],
|
|
52
|
+
imports: [
|
|
53
|
+
jwt_1.JwtModule.register({
|
|
54
|
+
secret: process.env.JWT_SECRET || 'your-secret-key',
|
|
55
|
+
signOptions: { expiresIn: '1d' },
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.AuthCoreModule = AuthCoreModule;
|
|
62
|
+
exports.AuthCoreModule = AuthCoreModule = AuthCoreModule_1 = __decorate([
|
|
63
|
+
(0, common_1.Module)({})
|
|
64
|
+
], AuthCoreModule);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { JwtService } from "@nestjs/jwt";
|
|
2
|
+
import { Repository } from "typeorm";
|
|
3
|
+
import { User } from "./entities/user.entity";
|
|
4
|
+
import { UserModuleAccess } from "./entities/user-module-access.entity";
|
|
5
|
+
import { UserFeatureAccess } from "./entities/user-feature-access.entity";
|
|
6
|
+
import { Feature } from "./entities/feature.entity";
|
|
7
|
+
import { ModuleRoute } from "./entities/module-route.entity";
|
|
8
|
+
import { ModuleScreenPermission } from "./entities/module-screen-permission.entity";
|
|
9
|
+
export declare class AuthService {
|
|
10
|
+
private jwtService;
|
|
11
|
+
private readonly userRepo;
|
|
12
|
+
private readonly config;
|
|
13
|
+
private readonly moduleAccessRepo;
|
|
14
|
+
private readonly featureAccessRepo;
|
|
15
|
+
private readonly featureRepo;
|
|
16
|
+
private readonly screenPermissionRepo;
|
|
17
|
+
private readonly routeRepo;
|
|
18
|
+
constructor(jwtService: JwtService, userRepo: Repository<User>, config: {
|
|
19
|
+
moduleId: number;
|
|
20
|
+
}, moduleAccessRepo: Repository<UserModuleAccess>, featureAccessRepo: Repository<UserFeatureAccess>, featureRepo: Repository<Feature>, screenPermissionRepo: Repository<ModuleScreenPermission>, routeRepo: Repository<ModuleRoute>);
|
|
21
|
+
validateUser(email: string, password: string): Promise<User | null>;
|
|
22
|
+
login(user: User): Promise<{
|
|
23
|
+
access_token: string;
|
|
24
|
+
}>;
|
|
25
|
+
findUserById(id: number): Promise<User | null>;
|
|
26
|
+
private loadPermissions;
|
|
27
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AuthService = void 0;
|
|
49
|
+
// src/auth.service.ts
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
52
|
+
const typeorm_1 = require("typeorm");
|
|
53
|
+
const typeorm_2 = require("@nestjs/typeorm");
|
|
54
|
+
const bcrypt = __importStar(require("bcrypt"));
|
|
55
|
+
const user_entity_1 = require("./entities/user.entity");
|
|
56
|
+
const user_module_access_entity_1 = require("./entities/user-module-access.entity");
|
|
57
|
+
const user_feature_access_entity_1 = require("./entities/user-feature-access.entity");
|
|
58
|
+
const feature_entity_1 = require("./entities/feature.entity");
|
|
59
|
+
const module_route_entity_1 = require("./entities/module-route.entity");
|
|
60
|
+
const module_screen_permission_entity_1 = require("./entities/module-screen-permission.entity");
|
|
61
|
+
let AuthService = class AuthService {
|
|
62
|
+
constructor(jwtService, userRepo, config, moduleAccessRepo, featureAccessRepo, featureRepo, screenPermissionRepo, routeRepo) {
|
|
63
|
+
this.jwtService = jwtService;
|
|
64
|
+
this.userRepo = userRepo;
|
|
65
|
+
this.config = config;
|
|
66
|
+
this.moduleAccessRepo = moduleAccessRepo;
|
|
67
|
+
this.featureAccessRepo = featureAccessRepo;
|
|
68
|
+
this.featureRepo = featureRepo;
|
|
69
|
+
this.screenPermissionRepo = screenPermissionRepo;
|
|
70
|
+
this.routeRepo = routeRepo;
|
|
71
|
+
}
|
|
72
|
+
async validateUser(email, password) {
|
|
73
|
+
const user = await this.userRepo.findOne({ where: { email } });
|
|
74
|
+
if (!user || user.moduleId !== this.config.moduleId)
|
|
75
|
+
return null;
|
|
76
|
+
const isValid = await bcrypt.compare(password, user.password);
|
|
77
|
+
return isValid ? user : null;
|
|
78
|
+
}
|
|
79
|
+
async login(user) {
|
|
80
|
+
const permissionTree = await this.loadPermissions(user.id);
|
|
81
|
+
const payload = {
|
|
82
|
+
id: user.id,
|
|
83
|
+
email: user.email,
|
|
84
|
+
roleId: user.roleId,
|
|
85
|
+
moduleId: user.moduleId,
|
|
86
|
+
permissions: permissionTree,
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
access_token: this.jwtService.sign(payload),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async findUserById(id) {
|
|
93
|
+
return this.userRepo.findOne({ where: { id } });
|
|
94
|
+
}
|
|
95
|
+
// private async loadPermissions(userId: number): Promise<any> {
|
|
96
|
+
// const featureAccessList = await this.featureAccessRepo.find({
|
|
97
|
+
// where: { userId: userId, isDeleted: 0 },
|
|
98
|
+
// });
|
|
99
|
+
// const permissions: Record<string, string[]> = {};
|
|
100
|
+
// for (const access of featureAccessList) {
|
|
101
|
+
// const feature = await this.featureRepo.findOne({
|
|
102
|
+
// where: { id: access.featureId },
|
|
103
|
+
// });
|
|
104
|
+
// if (!feature) continue;
|
|
105
|
+
// const perms: string[] = [];
|
|
106
|
+
// if (access.canView) perms.push("view");
|
|
107
|
+
// if (access.canCreate) perms.push("create");
|
|
108
|
+
// if (access.canModify) perms.push("update");
|
|
109
|
+
// if (access.canDelete) perms.push("delete");
|
|
110
|
+
// if (access.canImport) perms.push("import");
|
|
111
|
+
// if (access.canExport) perms.push("export");
|
|
112
|
+
// if (perms.length) {
|
|
113
|
+
// permissions[feature.featureName] = perms;
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
// const moduleAccess = await this.moduleAccessRepo.find({
|
|
117
|
+
// where: { userId: userId, isDeleted: 0 },
|
|
118
|
+
// });
|
|
119
|
+
// const moduleIds = moduleAccess.map((m) => m.moduleId);
|
|
120
|
+
// return {
|
|
121
|
+
// features: permissions,
|
|
122
|
+
// modules: moduleIds,
|
|
123
|
+
// };
|
|
124
|
+
// }
|
|
125
|
+
async loadPermissions(userId) {
|
|
126
|
+
// ---- Feature Permissions ----
|
|
127
|
+
const featureAccessList = await this.featureAccessRepo.find({
|
|
128
|
+
where: { userId, isDeleted: 0 },
|
|
129
|
+
});
|
|
130
|
+
const featurePermissions = {};
|
|
131
|
+
for (const access of featureAccessList) {
|
|
132
|
+
const feature = await this.featureRepo.findOne({
|
|
133
|
+
where: { id: access.featureId },
|
|
134
|
+
});
|
|
135
|
+
if (!feature)
|
|
136
|
+
continue;
|
|
137
|
+
const perms = [];
|
|
138
|
+
if (access.canView)
|
|
139
|
+
perms.push("view");
|
|
140
|
+
if (access.canCreate)
|
|
141
|
+
perms.push("create");
|
|
142
|
+
if (access.canModify)
|
|
143
|
+
perms.push("update");
|
|
144
|
+
if (access.canDelete)
|
|
145
|
+
perms.push("delete");
|
|
146
|
+
if (access.canImport)
|
|
147
|
+
perms.push("import");
|
|
148
|
+
if (access.canExport)
|
|
149
|
+
perms.push("export");
|
|
150
|
+
if (perms.length) {
|
|
151
|
+
featurePermissions[feature.featureName] = perms;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// ---- Module Access ----
|
|
155
|
+
const moduleAccess = await this.moduleAccessRepo.find({
|
|
156
|
+
where: { userId, isDeleted: 0 },
|
|
157
|
+
});
|
|
158
|
+
const moduleIds = moduleAccess.map((m) => m.moduleId);
|
|
159
|
+
// ---- Route Permissions ----
|
|
160
|
+
const screenPermissionsList = await this.screenPermissionRepo.find({
|
|
161
|
+
where: { userId, isActive: true },
|
|
162
|
+
});
|
|
163
|
+
const routePermissions = {};
|
|
164
|
+
for (const screen of screenPermissionsList) {
|
|
165
|
+
const route = await this.routeRepo.findOne({
|
|
166
|
+
where: { id: screen.moduleRouteId },
|
|
167
|
+
});
|
|
168
|
+
if (!route)
|
|
169
|
+
continue;
|
|
170
|
+
const perms = [];
|
|
171
|
+
const permissionKeys = [
|
|
172
|
+
"view",
|
|
173
|
+
"create",
|
|
174
|
+
"update",
|
|
175
|
+
"delete",
|
|
176
|
+
"import",
|
|
177
|
+
"export",
|
|
178
|
+
];
|
|
179
|
+
for (const key of permissionKeys) {
|
|
180
|
+
if (screen.permissions?.[key]) {
|
|
181
|
+
perms.push(key);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (perms.length) {
|
|
185
|
+
routePermissions[route.routeName] = perms;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
features: featurePermissions,
|
|
190
|
+
modules: moduleIds,
|
|
191
|
+
routes: routePermissions,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
exports.AuthService = AuthService;
|
|
196
|
+
exports.AuthService = AuthService = __decorate([
|
|
197
|
+
(0, common_1.Injectable)(),
|
|
198
|
+
__param(1, (0, typeorm_2.InjectRepository)(user_entity_1.User, "ecrs_main_connection")),
|
|
199
|
+
__param(2, (0, common_1.Inject)("MODULE_CONFIG")),
|
|
200
|
+
__param(3, (0, typeorm_2.InjectRepository)(user_module_access_entity_1.UserModuleAccess, "ecrs_main_connection")),
|
|
201
|
+
__param(4, (0, typeorm_2.InjectRepository)(user_feature_access_entity_1.UserFeatureAccess, "ecrs_main_connection")),
|
|
202
|
+
__param(5, (0, typeorm_2.InjectRepository)(feature_entity_1.Feature, "ecrs_main_connection")),
|
|
203
|
+
__param(6, (0, typeorm_2.InjectRepository)(module_screen_permission_entity_1.ModuleScreenPermission, "ecrs_main_connection")),
|
|
204
|
+
__param(7, (0, typeorm_2.InjectRepository)(module_route_entity_1.ModuleRoute, "ecrs_main_connection")),
|
|
205
|
+
__metadata("design:paramtypes", [jwt_1.JwtService,
|
|
206
|
+
typeorm_1.Repository, Object, typeorm_1.Repository,
|
|
207
|
+
typeorm_1.Repository,
|
|
208
|
+
typeorm_1.Repository,
|
|
209
|
+
typeorm_1.Repository,
|
|
210
|
+
typeorm_1.Repository])
|
|
211
|
+
], AuthService);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = void 0;
|
|
4
|
+
// src/decorators/current-user.decorator.ts
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
7
|
+
const request = ctx.switchToHttp().getRequest();
|
|
8
|
+
return request.user;
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HasFeature: (permission: string, feature: string) => import("@nestjs/common").CustomDecorator<string>[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HasFeature = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const HasFeature = (permission, feature) => {
|
|
6
|
+
return [
|
|
7
|
+
(0, common_1.SetMetadata)('feature_permission', permission),
|
|
8
|
+
(0, common_1.SetMetadata)('feature_name', feature),
|
|
9
|
+
];
|
|
10
|
+
};
|
|
11
|
+
exports.HasFeature = HasFeature;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HasPermission = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const HasPermission = (options) => {
|
|
6
|
+
return (0, common_1.SetMetadata)('combined_permission', options);
|
|
7
|
+
};
|
|
8
|
+
exports.HasPermission = HasPermission;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Roles: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HasRoutePermission: (permission: string, route: string) => import("@nestjs/common").CustomDecorator<string>[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HasRoutePermission = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const HasRoutePermission = (permission, route) => {
|
|
6
|
+
return [
|
|
7
|
+
(0, common_1.SetMetadata)('route_permission', permission),
|
|
8
|
+
(0, common_1.SetMetadata)('route_name', route),
|
|
9
|
+
];
|
|
10
|
+
};
|
|
11
|
+
exports.HasRoutePermission = HasRoutePermission;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Feature = void 0;
|
|
13
|
+
// src/entities/feature.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let Feature = class Feature {
|
|
16
|
+
};
|
|
17
|
+
exports.Feature = Feature;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], Feature.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'module_id' }),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], Feature.prototype, "moduleId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'feature_name', length: 100, unique: true }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], Feature.prototype, "featureName", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'feature_description', length: 255, nullable: true }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], Feature.prototype, "featureDescription", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ type: 'smallint', default: 1 }),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], Feature.prototype, "status", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
40
|
+
__metadata("design:type", Date)
|
|
41
|
+
], Feature.prototype, "createdAt", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
44
|
+
__metadata("design:type", Date)
|
|
45
|
+
], Feature.prototype, "updatedAt", void 0);
|
|
46
|
+
exports.Feature = Feature = __decorate([
|
|
47
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_features' })
|
|
48
|
+
], Feature);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ModuleRoute = void 0;
|
|
13
|
+
// src/entities/module-route.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let ModuleRoute = class ModuleRoute {
|
|
16
|
+
};
|
|
17
|
+
exports.ModuleRoute = ModuleRoute;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], ModuleRoute.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'module_id' }),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], ModuleRoute.prototype, "moduleId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'sub_module_name' }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], ModuleRoute.prototype, "subModuleName", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'route_name' }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], ModuleRoute.prototype, "routeName", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'parent_sub_id', nullable: true }),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], ModuleRoute.prototype, "parentSubId", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'parent_sub_sub_id', nullable: true }),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], ModuleRoute.prototype, "parentSubSubId", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'is_active', default: true }),
|
|
44
|
+
__metadata("design:type", Boolean)
|
|
45
|
+
], ModuleRoute.prototype, "isActive", void 0);
|
|
46
|
+
exports.ModuleRoute = ModuleRoute = __decorate([
|
|
47
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_master_module_routes' })
|
|
48
|
+
], ModuleRoute);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class ModuleScreenPermission {
|
|
2
|
+
id: number;
|
|
3
|
+
moduleRouteId: number;
|
|
4
|
+
userId: number;
|
|
5
|
+
permissions: {
|
|
6
|
+
view?: boolean;
|
|
7
|
+
create?: boolean;
|
|
8
|
+
update?: boolean;
|
|
9
|
+
delete?: boolean;
|
|
10
|
+
import?: boolean;
|
|
11
|
+
export?: boolean;
|
|
12
|
+
};
|
|
13
|
+
isActive: boolean;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ModuleScreenPermission = void 0;
|
|
13
|
+
// src/entities/module-screen-permission.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let ModuleScreenPermission = class ModuleScreenPermission {
|
|
16
|
+
};
|
|
17
|
+
exports.ModuleScreenPermission = ModuleScreenPermission;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], ModuleScreenPermission.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'module_route_id' }),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], ModuleScreenPermission.prototype, "moduleRouteId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'user_id' }),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], ModuleScreenPermission.prototype, "userId", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: 'json' }),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], ModuleScreenPermission.prototype, "permissions", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'is_active', default: true }),
|
|
36
|
+
__metadata("design:type", Boolean)
|
|
37
|
+
], ModuleScreenPermission.prototype, "isActive", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
40
|
+
__metadata("design:type", Date)
|
|
41
|
+
], ModuleScreenPermission.prototype, "createdAt", void 0);
|
|
42
|
+
exports.ModuleScreenPermission = ModuleScreenPermission = __decorate([
|
|
43
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_master_module_wise_screen_permission' })
|
|
44
|
+
], ModuleScreenPermission);
|