@jarbotickets/common 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.
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAE9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
|
@@ -3,14 +3,4 @@ export interface UserPayload {
|
|
|
3
3
|
id: string;
|
|
4
4
|
email: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
session?: {
|
|
8
|
-
jwt?: string;
|
|
9
|
-
} | null;
|
|
10
|
-
}
|
|
11
|
-
export declare const currentUser: (req: SessionRequest, res: Response & {
|
|
12
|
-
locals: {
|
|
13
|
-
currentUser: UserPayload | null;
|
|
14
|
-
};
|
|
15
|
-
}, next: NextFunction) => Promise<void>;
|
|
16
|
-
export {};
|
|
6
|
+
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import jwt from "jsonwebtoken";
|
|
2
2
|
export const currentUser = async (req, res, next) => {
|
|
3
|
-
|
|
3
|
+
const token = req.session
|
|
4
|
+
?.jwt;
|
|
5
|
+
if (!token) {
|
|
4
6
|
res.locals.currentUser = null;
|
|
5
7
|
return next();
|
|
6
8
|
}
|
|
7
9
|
try {
|
|
8
|
-
const payload = jwt.verify(
|
|
10
|
+
const payload = jwt.verify(token, process.env.JWT_KEY);
|
|
9
11
|
res.locals.currentUser = payload;
|
|
10
12
|
next();
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,cAAc,CAAC;AAO/B,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,GAAY,EACZ,GAAa,EACb,IAAkB,EAClB,EAAE;IACF,MAAM,KAAK,GAAI,GAAuD,CAAC,OAAO;QAC5E,EAAE,GAAG,CAAC;IACR,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CACxB,KAAK,EACL,OAAO,CAAC,GAAG,CAAC,OAAsB,CACpB,CAAC;QACjB,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC;QACjC,IAAI,EAAE,CAAC;IACT,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|