mbkauthe 1.0.17 → 1.0.18

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/lib/main.js +7 -9
  2. package/package.json +1 -1
package/lib/main.js CHANGED
@@ -79,12 +79,8 @@ router.use(async (req, res, next) => {
79
79
  req.session.user = {
80
80
  id: user.id,
81
81
  username: user.UserName,
82
- UserName: user.UserName,
83
- Role: user.Role,
84
- role: user.Role,
85
82
  sessionId,
86
83
  };
87
- console.log(`Session restored for user: ${user.UserName}`);
88
84
  }
89
85
  } catch (err) {
90
86
  console.error("Session restoration error:", err);
@@ -273,11 +269,13 @@ router.post("/mbkauthe/api/logout", async (req, res) => {
273
269
  if (req.session.user) {
274
270
  try {
275
271
  const { id, username } = req.session.user;
276
- const query = `SELECT "Active" FROM "Users" WHERE "id" = $1`;
277
- const result = await dblogin.query(query, [id]);
278
-
279
- if (result.rows.length > 0 && !result.rows[0].Active) {
280
- console.log("Account is inactive during logout");
272
+
273
+ // Clear the SessionId in the database first
274
+ await dblogin.query(`UPDATE "Users" SET "SessionId" = NULL WHERE "id" = $1`, [id]);
275
+
276
+ // Remove the session from the session table
277
+ if (req.sessionID) {
278
+ await dblogin.query('DELETE FROM "session" WHERE sid = $1', [req.sessionID]);
281
279
  }
282
280
 
283
281
  req.session.destroy((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mbkauthe",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "MBKTechStudio's reusable authentication system for Node.js applications.",
5
5
  "main": "index.js",
6
6
  "type": "module",