ecrs-auth-core 1.0.37 → 1.0.38

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.
@@ -4,6 +4,16 @@ export declare class AuthController {
4
4
  private readonly authService;
5
5
  constructor(authService: AuthService);
6
6
  login(body: LoginDto): Promise<{
7
+ status: boolean;
8
+ message: string;
9
+ data: {
10
+ user: {
11
+ id: number;
12
+ email: string;
13
+ roleId: number;
14
+ moduleId: number;
15
+ };
16
+ };
7
17
  access_token: string;
8
18
  }>;
9
19
  }
@@ -13,7 +13,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AuthController = void 0;
16
- // src/auth.controller.ts
17
16
  const common_1 = require("@nestjs/common");
18
17
  const auth_service_1 = require("./auth.service");
19
18
  const login_dto_1 = require("./dtos/login.dto");
@@ -23,6 +23,16 @@ export declare class AuthService {
23
23
  constructor(jwtService: JwtService, options: AuthCoreOptions);
24
24
  validateUser(email: string, password: string): Promise<User | null>;
25
25
  login(user: User): Promise<{
26
+ status: boolean;
27
+ message: string;
28
+ data: {
29
+ user: {
30
+ id: number;
31
+ email: string;
32
+ roleId: number;
33
+ moduleId: number;
34
+ };
35
+ };
26
36
  access_token: string;
27
37
  }>;
28
38
  findUserById(id: number): Promise<User | null>;
@@ -81,6 +81,16 @@ let AuthService = class AuthService {
81
81
  permissions: permissionTree,
82
82
  };
83
83
  return {
84
+ status: true,
85
+ message: 'Login successful',
86
+ data: {
87
+ user: {
88
+ id: user.id,
89
+ email: user.email,
90
+ roleId: user.roleId,
91
+ moduleId: user.moduleId,
92
+ },
93
+ },
84
94
  access_token: this.jwtService.sign(payload),
85
95
  };
86
96
  }
@@ -1,6 +1,7 @@
1
1
  export declare class Role {
2
2
  id: number;
3
+ module_id: number;
3
4
  roleName: string;
4
- roleDescription?: string;
5
+ roleDescription: string;
5
6
  isActive: boolean;
6
7
  }
@@ -10,25 +10,33 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Role = void 0;
13
- // src/entities/role.entity.ts
14
13
  const typeorm_1 = require("typeorm");
15
14
  let Role = class Role {
16
15
  };
17
16
  exports.Role = Role;
18
17
  __decorate([
19
- (0, typeorm_1.PrimaryGeneratedColumn)(),
18
+ (0, typeorm_1.PrimaryGeneratedColumn)('increment', { name: 'id' }),
20
19
  __metadata("design:type", Number)
21
20
  ], Role.prototype, "id", void 0);
22
21
  __decorate([
23
- (0, typeorm_1.Column)({ name: 'role_name', length: 100, unique: true }),
22
+ (0, typeorm_1.Column)({ name: 'module_id', type: 'int', nullable: true }),
23
+ __metadata("design:type", Number)
24
+ ], Role.prototype, "module_id", void 0);
25
+ __decorate([
26
+ (0, typeorm_1.Column)({ name: 'role_name', type: 'varchar', length: 100, unique: true }),
24
27
  __metadata("design:type", String)
25
28
  ], Role.prototype, "roleName", void 0);
26
29
  __decorate([
27
- (0, typeorm_1.Column)({ name: 'role_description', length: 255, nullable: true }),
30
+ (0, typeorm_1.Column)({
31
+ name: 'role_description',
32
+ type: 'varchar',
33
+ length: 255,
34
+ nullable: true,
35
+ }),
28
36
  __metadata("design:type", String)
29
37
  ], Role.prototype, "roleDescription", void 0);
30
38
  __decorate([
31
- (0, typeorm_1.Column)({ name: 'is_active', default: true }),
39
+ (0, typeorm_1.Column)({ name: 'is_active', type: 'boolean', default: true }),
32
40
  __metadata("design:type", Boolean)
33
41
  ], Role.prototype, "isActive", void 0);
34
42
  exports.Role = Role = __decorate([
@@ -1,58 +1,36 @@
1
1
  "use strict";
2
- var __decorate =
3
- (this && this.__decorate) ||
4
- function (decorators, target, key, desc) {
5
- var c = arguments.length,
6
- r =
7
- c < 3
8
- ? target
9
- : desc === null
10
- ? (desc = Object.getOwnPropertyDescriptor(target, key))
11
- : desc,
12
- d;
13
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
14
- r = Reflect.decorate(decorators, target, key, desc);
15
- else
16
- for (var i = decorators.length - 1; i >= 0; i--)
17
- if ((d = decorators[i]))
18
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
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;
19
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
20
- };
21
- var __metadata =
22
- (this && this.__metadata) ||
23
- function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
25
- return Reflect.metadata(k, v);
26
- };
27
- var __param =
28
- (this && this.__param) ||
29
- function (paramIndex, decorator) {
30
- return function (target, key) {
31
- decorator(target, key, paramIndex);
32
- };
33
- };
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
+ };
34
14
  Object.defineProperty(exports, "__esModule", { value: true });
35
15
  exports.ModuleGuard = void 0;
36
16
  const common_1 = require("@nestjs/common");
37
17
  let ModuleGuard = class ModuleGuard {
38
- constructor(config) {
39
- this.config = config;
40
- }
41
- canActivate(context) {
42
- const request = context.switchToHttp().getRequest();
43
- const user = request.user;
44
- // SuperAdmin can bypass module checks
45
- const isSuperAdmin = user.roleId === 1;
46
- if (isSuperAdmin) return true;
47
- return user.moduleId === this.config.moduleId;
48
- }
18
+ constructor(config) {
19
+ this.config = config;
20
+ }
21
+ canActivate(context) {
22
+ const request = context.switchToHttp().getRequest();
23
+ const user = request.user;
24
+ // SuperAdmin can bypass module checks
25
+ const isSuperAdmin = user.roleId === 1;
26
+ if (isSuperAdmin)
27
+ return true;
28
+ return user.moduleId === this.config.moduleId;
29
+ }
49
30
  };
50
31
  exports.ModuleGuard = ModuleGuard;
51
- exports.ModuleGuard = ModuleGuard = __decorate(
52
- [
32
+ exports.ModuleGuard = ModuleGuard = __decorate([
53
33
  (0, common_1.Injectable)(),
54
- __param(0, (0, common_1.Inject)("MODULE_CONFIG")),
55
- __metadata("design:paramtypes", [Object]),
56
- ],
57
- ModuleGuard
58
- );
34
+ __param(0, (0, common_1.Inject)('MODULE_CONFIG')),
35
+ __metadata("design:paramtypes", [Object])
36
+ ], ModuleGuard);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",