nodebb-plugin-anti-account-sharing 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/library.js +7 -20
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -56,28 +56,15 @@ Plugin.checkSession = async function (data) {
56
56
  const sid = req.sessionID;
57
57
  if (!sid) return data;
58
58
 
59
- const key = `antishare:sessionsz:${req.uid}`; // <-- yeni key
59
+ const key = `antishare:sessionsz:${req.uid}`;
60
60
 
61
- // allowed = en yeni MAX_DEVICES session
62
- let newest = await db.getSortedSetRevRange(key, 0, -1);
61
+ // Sadece en yeni MAX_DEVICES session allowed
62
+ const allowed = await db.getSortedSetRevRange(key, 0, MAX_DEVICES - 1);
63
63
 
64
- // Fallback: eğer hiç kayıt yoksa veya bu sid listede yoksa (ilk defa görüyorsak) ekle
65
- // (AMA mevcut sid varsa score'u güncelleme! yoksa eski session kendini "yeniler" ve kick yemez)
66
- if (!newest.includes(sid)) {
67
- await db.sortedSetAdd(key, Date.now(), sid);
68
- newest = await db.getSortedSetRevRange(key, 0, -1);
69
- }
64
+ // Eğer henüz kayıt yoksa (çok nadir) karışma
65
+ if (!Array.isArray(allowed) || !allowed.length) return data;
70
66
 
71
- // Trim (fazla varsa sil)
72
- const toRemove = newest.slice(MAX_DEVICES);
73
- if (toRemove.length) {
74
- await db.sortedSetRemove(key, toRemove);
75
- newest = newest.slice(0, MAX_DEVICES);
76
- }
77
-
78
- const allowed = newest; // en yeni MAX_DEVICES
79
-
80
- // Bu session allowed değilse -> kick
67
+ // allowed değilse -> kick
81
68
  if (!allowed.includes(sid)) {
82
69
  try { req.logout?.(); } catch (e) {}
83
70
  if (req.session) {
@@ -97,7 +84,7 @@ Plugin.checkSession = async function (data) {
97
84
  res.redirect('/login?error=session-conflict');
98
85
  return;
99
86
  }
100
-
87
+
101
88
  return data;
102
89
  };
103
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-anti-account-sharing",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Prevents account sharing by enforcing a single active session policy for desktop devices.",
5
5
  "main": "library.js",
6
6
  "keywords": [