@jpbs/common 1.2.3 → 1.2.5

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.
@@ -6,11 +6,10 @@ export declare enum Role {
6
6
  export interface AuthenticatedRequest extends Request {
7
7
  currentUser?: IDecodedUser;
8
8
  }
9
- interface IDecodedUser {
9
+ export interface IDecodedUser {
10
10
  id: string;
11
11
  email: string;
12
12
  username: string;
13
13
  role: Role;
14
14
  }
15
15
  export declare const authenticationGuard: (jwtSecret: string) => (req: AuthenticatedRequest, res: Response, next: NextFunction) => Promise<void>;
16
- export {};
@@ -28,12 +28,12 @@ const authenticationGuard = (jwtSecret) => (req, res, next) => __awaiter(void 0,
28
28
  res.status(http_status_codes_1.StatusCodes.UNAUTHORIZED).json({ error: "Unauthorized" });
29
29
  return;
30
30
  }
31
- const isRevoked = yield (0, redisClient_1.isTokenRevoked)(token);
31
+ const decoded = jsonwebtoken_1.default.verify(token, jwtSecret);
32
+ const isRevoked = yield (0, redisClient_1.isTokenRevoked)(token, decoded.id);
32
33
  if (isRevoked) {
33
34
  res.status(http_status_codes_1.StatusCodes.UNAUTHORIZED).json({ error: "Token has been revoked" });
34
35
  return;
35
36
  }
36
- const decoded = jsonwebtoken_1.default.verify(token, jwtSecret);
37
37
  req.currentUser = decoded;
38
38
  next();
39
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpbs/common",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [