techiediaries / fake-api-jwt-json-server

A Fake API with JWT Authentication using json-server and jsonwebtoken

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

function verifyToken return error not throw it

Pavel-Evdokimov opened this issue · comments

commented

Hi!
When I try to get access to fake-api with this get request
GET http://localhost:3000/products Authorization: Bearer
I get all the data. But I think I shouldn't. I expecting to get an error "jwt must be provided".
I guess code should be corrected some how like this
let verifyTokenResult; try { verifyTokenResult = verifyToken(req.headers.authorization.split(' ')[1]); if (verifyTokenResult instanceof Error) { throw verifyTokenResult; } next()