Skip to content

Commit

Permalink
Added new check in verifyRToken route
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaxuGarg committed Aug 25, 2021
1 parent cd031ee commit cbcea9b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,18 @@ router.get('/verifyRToken', async (req, res) => {
}
const user = await verifyToken(req, res);
const clientId = await rtoken.hget(requestToken.toString(), 'cId');
const client = await Client.findById(clientId);

if (!client) {
return res.status(400).json({
err: true,
msg: 'No client found',
});
}

verify(requestToken, client.access_token, {
algorithms: ['HS256'],
});
rtoken.hmset(requestToken.toString(), {
cId: clientId,
uId: user._id.toString(),
Expand Down

0 comments on commit cbcea9b

Please sign in to comment.