Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11866 from Uzlopak/fix-lgtm-warnings
chore: fix lgtm warnings
- Loading branch information
Showing
9 changed files
with
45 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const JWT_SECRET = 'token'; | ||
|
||
module.exports = { | ||
JWT_SECRET | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
'use strict'; | ||
|
||
const jwt = require('jsonwebtoken'); | ||
const JWT_SECRET = require('../config').JWT_SECRET; | ||
|
||
module.exports = async function(req, res, next) { | ||
try { | ||
const authToken = req.header('x-auth'); | ||
if (!authToken) return res.status(404).send({ msg: 'AuthToken not found' }); | ||
|
||
const decodedValue = jwt.verify(authToken, 'token'); | ||
const decodedValue = jwt.verify(authToken, JWT_SECRET); | ||
if (!decodedValue) return res.status(401).send({ msg: 'Invalid Authentication' }); | ||
|
||
req.userId = decodedValue.userId; | ||
next(); | ||
} catch (err) { | ||
res.status(401).send({ msg: 'Invalid Authentication:' + err }); | ||
res.status(401).send({ msg: 'Invalid Authentication'}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters