ecrs-auth-core 1.0.100 → 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/auth.service.js +1 -1
- package/dist/jwt/jwt.strategy.js +25 -17
- package/package.json +1 -1
package/dist/auth.service.js
CHANGED
|
@@ -171,7 +171,7 @@ let AuthService = class AuthService {
|
|
|
171
171
|
AND status = 1
|
|
172
172
|
AND is_deleted = 0
|
|
173
173
|
LIMIT 1`, [userId, moduleId]);
|
|
174
|
-
|
|
174
|
+
console.log('Raw Query Result:', result);
|
|
175
175
|
const allowed = result.length > 0;
|
|
176
176
|
console.log(`📊 Module access check result for user ID ${userId} and module ID ${moduleId}: ${allowed ? 'Allowed' : 'Denied'}`);
|
|
177
177
|
return allowed;
|
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,
|