ecrs-auth-core 1.0.87 → 1.0.89

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.
@@ -50,10 +50,14 @@ let AuthController = class AuthController {
50
50
  }
51
51
  console.log('📊 User details:', user);
52
52
  const requestedModuleId = Number(body.moduleId);
53
+ console.log(`📍 User ${body.email} requested access to module ID: ${requestedModuleId}`);
53
54
  if (!Number.isFinite(requestedModuleId)) {
55
+ console.warn(`⚠️ Invalid module ID provided by user ${body.email}: ${body.moduleId}`);
54
56
  throw new common_1.UnauthorizedException('You are not authorized to access this module');
55
57
  }
58
+ console.log(`🔍 Checking module access for user ID ${user.id} and module ID ${requestedModuleId}...`);
56
59
  const allowedDb = await this.authService.hasModuleAccess(user.id, requestedModuleId);
60
+ console.log(`📊 Module access check result for user ID ${user.id} and module ID ${requestedModuleId}: ${allowedDb ? 'Allowed' : 'Denied'}`);
57
61
  if (!allowedDb) {
58
62
  throw new common_1.UnauthorizedException('You are not authorized to access this module');
59
63
  }
@@ -163,9 +163,20 @@ let AuthService = class AuthService {
163
163
  async hasModuleAccess(userId, moduleId) {
164
164
  if (!Number.isFinite(moduleId))
165
165
  return false;
166
+ console.log(`🔍 Checking module access for user ID ${userId} and module ID ${moduleId}...`);
166
167
  const access = await this.moduleAccessRepo.findOne({
167
168
  where: { userId, moduleId, isDeleted: 0, status: 1 },
168
169
  });
170
+ console.log(access);
171
+ const access1 = await this.moduleAccessRepo
172
+ .createQueryBuilder("ma")
173
+ .where("ma.userId = :userId", { userId })
174
+ .andWhere("ma.moduleId = :moduleId", { moduleId })
175
+ .andWhere("ma.status = 1")
176
+ .andWhere("ma.isDeleted = 0")
177
+ .getOne();
178
+ console.log(access1);
179
+ console.log(`📊 Module access check result for user ID ${userId} and module ID ${moduleId}: ${access ? 'Allowed' : 'Denied'}`);
169
180
  return !!access;
170
181
  }
171
182
  async getPermissions(userId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.87",
3
+ "version": "1.0.89",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",