aloux-iam 0.0.89 → 0.0.90

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/middleware.js +16 -5
  2. package/package.json +1 -1
package/lib/middleware.js CHANGED
@@ -65,15 +65,26 @@ const auth = async (req, res, next) => {
65
65
  }
66
66
 
67
67
  //Time session
68
- if(process.env.SESSION_INTERRUPTOR === "true"){
69
- const userTokens = await User.findOne({ _id: user._id, status: "Activo" },{ tokens: 1 }).lean()
70
- const tokenObject = userTokens.tokens.find(t => t.token === token);
68
+ if (process.env.SESSION_INTERRUPTOR === "true") {
69
+ const userTokens = await User.findOne(
70
+ { _id: user._id, status: "Activo" },
71
+ { tokens: 1 }
72
+ ).lean();
73
+ const tokenObject = userTokens.tokens.find((t) => t.token === token);
71
74
  if (tokenObject.dateEnd <= Date.now()) {
75
+ await User.updateOne(
76
+ { _id: userTokens._id },
77
+ {
78
+ $pull: {
79
+ tokens: { token: tokenObject.tokens.token }, // Condición para eliminar el token específico
80
+ },
81
+ }
82
+ );
72
83
  throw {
73
- code: 310,
84
+ code: 401,
74
85
  title: "La sesión expiró",
75
86
  detail: "Has llegado al tiempo límite de tu sesión",
76
- suggestion: "Extiende la duración de tu sesión",
87
+ suggestion: "Se eliminó la sesión vencida",
77
88
  error: new Error(),
78
89
  };
79
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aloux-iam",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "description": "Aloux IAM for APIs ",
5
5
  "main": "index.js",
6
6
  "scripts": {