plum-e2e 2.4.2 → 2.4.3
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/backend/middleware/jwtAuth.js +14 -2
- package/bin/plum.js +3 -3
- package/package.json +1 -1
|
@@ -40,12 +40,24 @@ function jwtAuth(req, res, next) {
|
|
|
40
40
|
if (!auth || !auth.startsWith('Bearer ')) {
|
|
41
41
|
return res.status(401).json({ error: 'Unauthorized' });
|
|
42
42
|
}
|
|
43
|
+
let payload;
|
|
43
44
|
try {
|
|
44
|
-
|
|
45
|
-
next();
|
|
45
|
+
payload = verifyToken(auth.slice(7));
|
|
46
46
|
} catch {
|
|
47
47
|
return res.status(401).json({ error: 'Invalid or expired token' });
|
|
48
48
|
}
|
|
49
|
+
// Confirm the user still exists — catches stale JWTs after a DB reset
|
|
50
|
+
prisma.user
|
|
51
|
+
.findUnique({ where: { id: payload.userId }, select: { id: true } })
|
|
52
|
+
.then((user) => {
|
|
53
|
+
if (!user) return res.status(401).json({ error: 'Session expired. Please log in again.' });
|
|
54
|
+
req.user = payload;
|
|
55
|
+
next();
|
|
56
|
+
})
|
|
57
|
+
.catch(() => {
|
|
58
|
+
req.user = payload;
|
|
59
|
+
next();
|
|
60
|
+
});
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
module.exports = { jwtAuth };
|
package/bin/plum.js
CHANGED
|
@@ -318,9 +318,9 @@ async function serverStart() {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
clack.log.info(pc.
|
|
322
|
-
|
|
323
|
-
clack.outro(pc.
|
|
321
|
+
clack.log.info(`UI: ${pc.cyan(`http://localhost:${cfg.frontendPort}`)}`);
|
|
322
|
+
clack.log.info(`API: ${pc.cyan(`http://localhost:${cfg.backendPort}`)}`);
|
|
323
|
+
clack.outro(pc.green('Plum is running. Use "plum server stop" to shut down.'));
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
async function serverReconfig() {
|