Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions middleware/authenticateToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ const authToken = async (req, res, next) => {
},
],
});
}

// Authenticate token
try {
const user = await jwt.verify(token, process.env.ACCESS_TOKEN_SECRET);
req.user = user.email;
next();
} catch (error) {
res.status(403).json({
errors: [
{
msg: "Invalid token",
},
],
});
} else {
// Authenticate token
try {
const user = await jwt.verify(token, process.env.ACCESS_TOKEN_SECRET);
req.user = user.email;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saving the user emails too

next();
} catch (error) {
res.status(403).json({
errors: [
{
msg: "Invalid token",
},
],
});
}
}
};

Expand Down