|
@@ -4,11 +4,13 @@ module.exports = function ( req, res, next ) {
|
|
|
let token = req.headers['x-access-token'] || req.headers['authorization']
|
|
|
let checkBearer = 'Bearer '
|
|
|
|
|
|
- if (token.startsWith(checkBearer)) {
|
|
|
- token = token.slice(checkBearer.length, token.length)
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
if (token) {
|
|
|
+
|
|
|
+ if (token.startsWith(checkBearer)) {
|
|
|
+ token = token.slice(checkBearer.length, token.length)
|
|
|
+ }
|
|
|
+
|
|
|
jwt.verify(token, process.env.SECRET, (err, decoded) => {
|
|
|
if (err) {
|
|
|
res.json({
|