Skip to content

Commit 7e8d2f6

Browse files
authored
Add JWT expiration
1 parent ceb75b6 commit 7e8d2f6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

node/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ const PORT = process.env["PORT"] ? parseInt(process.env["PORT"]) : 3001;
99
let MB_SITE_URL = "http://localhost:3000";
1010
let MB_EMBEDDING_SECRET_KEY = "a1c0952f3ff361f1e7dd8433a0a50689a004317a198ecb0a67ba90c73c27a958";
1111

12-
let payload = {
13-
resource: { dashboard: 1 },
14-
params: {}
15-
};
16-
1712
function checkAuth(req, res, next) {
1813
const userId = req.session.userId;
1914
if(userId) {
@@ -69,7 +64,8 @@ app.get("/signed_chart/:id", checkAuth, (req, res) => {
6964
const userId = req.session.userId;
7065
const unsignedToken = {
7166
resource: { question: 2 },
72-
params: { person_id: userId }
67+
params: { person_id: userId },
68+
exp: Math.round(Date.now() / 1000) + (10 * 60) // 10 minute expiration
7369
};
7470

7571
// sign the JWT token with our secret key

0 commit comments

Comments
 (0)