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.
- package/dist/jwt/jwt.strategy.js +25 -17
- package/package.json +1 -1
package/dist/jwt/jwt.strategy.js
CHANGED
|
@@ -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
|
-
|
|
48
|
-
}
|
|
49
|
-
const lastActivityTime = new Date(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
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,
|