@misalon/common 1.0.16 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,12 @@ export interface AppointmentCreatedEvent {
11
11
  duration: number;
12
12
  category: ServiceCategory;
13
13
  };
14
- userId: string;
14
+ user: {
15
+ id: string;
16
+ firstName: string;
17
+ lastName: string;
18
+ email: string;
19
+ };
15
20
  date: string;
16
21
  time: string;
17
22
  status: string;
@@ -7,21 +7,19 @@ exports.currentUser = void 0;
7
7
  var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
8
  var currentUser = function (req, res, next) {
9
9
  var _a, _b;
10
- console.log('Session JWT:', (_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt); // Log the JWT from session
10
+ console.log('[auth] Session JWT:', (_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt); // Log session JWT
11
11
  if (!((_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt)) {
12
- console.log('No JWT in session, skipping user authentication');
13
- return next(); // No JWT in session, move to the next middleware
12
+ console.log('[auth] No JWT in session, skipping user authentication');
13
+ return next();
14
14
  }
15
15
  try {
16
- // Log before decoding
17
- console.log('Attempting to decode JWT...');
18
16
  var payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
19
- console.log('Decoded JWT Payload:', payload); // Log the decoded payload
20
- req.currentUser = payload; // Attach user information to request
17
+ req.currentUser = payload;
18
+ console.log('[auth] Current User:', req.currentUser);
21
19
  }
22
20
  catch (err) {
23
- console.error('Error decoding JWT:', err); // Log any decoding errors
21
+ console.error('[auth] Error decoding JWT:', err);
24
22
  }
25
- next(); // Proceed to the next middleware or route handler
23
+ next();
26
24
  };
27
25
  exports.currentUser = currentUser;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misalon/common",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [