ecrs-auth-core 1.0.101 → 1.0.102

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.
@@ -42,23 +42,31 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
42
42
  console.log(`✅ User ${user.id} has access to module ${payload.moduleId}`);
43
43
  }
44
44
  // 🔥 3. SESSION / LAST ACTIVITY CHECK
45
- const lastLogin = await this.authService.findUserLastLogin(user.id);
46
- if (!lastLogin) {
47
- throw new common_1.UnauthorizedException('SESSION_NOT_FOUND');
48
- }
49
- const lastActivityTime = new Date(lastLogin.lastActivityTime || lastLogin.login_time).getTime();
50
- const currentTime = Date.now();
51
- const inactivityMinutes = (currentTime - lastActivityTime) / (1000 * 60);
52
- const INACTIVITY_TIMEOUT_MINUTES = 20;
53
- // 🔥 Idle timeout
54
- if (inactivityMinutes > INACTIVITY_TIMEOUT_MINUTES) {
55
- console.log(`❌ User ${user.id} token expired due to inactivity (${inactivityMinutes.toFixed(2)} minutes)`);
56
- throw new common_1.UnauthorizedException('Your session has expired due to inactivity. Please login again.');
57
- }
58
- // 🔥 4. UPDATE LAST ACTIVITY (avoid DB overload)
59
- if (inactivityMinutes > 2) {
60
- await this.authService.updateLastActivity(lastLogin.id);
61
- }
45
+ // const lastLogin = await this.authService.findUserLastLogin(user.id);
46
+ // if (!lastLogin) {
47
+ // throw new UnauthorizedException('SESSION_NOT_FOUND');
48
+ // }
49
+ // const lastActivityTime = new Date(
50
+ // lastLogin.lastActivityTime || lastLogin.login_time,
51
+ // ).getTime();
52
+ // const currentTime = Date.now();
53
+ // const inactivityMinutes = (currentTime - lastActivityTime) / (1000 * 60);
54
+ // const INACTIVITY_TIMEOUT_MINUTES = 20;
55
+ // // 🔥 Idle timeout
56
+ // if (inactivityMinutes > INACTIVITY_TIMEOUT_MINUTES) {
57
+ // console.log(
58
+ // `❌ User ${user.id} token expired due to inactivity (${inactivityMinutes.toFixed(
59
+ // 2,
60
+ // )} minutes)`,
61
+ // );
62
+ // throw new UnauthorizedException(
63
+ // 'Your session has expired due to inactivity. Please login again.',
64
+ // );
65
+ // }
66
+ // // 🔥 4. UPDATE LAST ACTIVITY (avoid DB overload)
67
+ // if (inactivityMinutes > 2) {
68
+ // await this.authService.updateLastActivity(lastLogin.id);
69
+ // }
62
70
  console.log(`✅ JWT validated for user ${user.id}`);
63
71
  return {
64
72
  id: user.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.101",
3
+ "version": "1.0.102",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",