cityofaustin / ctxfloods

Central Texas Floods
11 stars 5 forks source link

JsonWebTokenError: invalid signature #353

Closed Niicck closed 6 years ago

Niicck commented 6 years ago

If our JSON web token key ever changes on the backend, then the frontend will be "loading" indefinitely. If you're a developer, you'd know to open the inspector and clear the old jwt from local storage. But we need a way to automatically remove the existing token from localstorage if the frontend receives this error.

{ JsonWebTokenError: invalid signature at Object.module.exports [as verify] (/Users/nicholasivons/City/ctxfloods-backend/node_modules/postgraphql/node_modules/jsonwebtoken/verify.js:107:17) at Object. (/Users/nicholasivons/City/ctxfloods-backend/node_modules/postgraphql/build/postgraphql/http/setupRequestPgClientTransaction.js:37:45) at step (/Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:133:27) at Object.next (/Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:114:57) at /Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:107:75 at new Promise () at Object.awaiter (/Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:103:16) at Object.setupRequestPgClientTransaction [as default] (/Users/nicholasivons/City/ctxfloods-backend/node_modules/postgraphql/build/postgraphql/http/setupRequestPgClientTransaction.js:20:20) at pgClient.query.then (/Users/nicholasivons/City/ctxfloods-backend/handlers/graphqlHandler.js:42:21) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) name: 'JsonWebTokenError', message: 'invalid signature', statusCode: 403 } (node:71646) UnhandledPromiseRejectionWarning: RangeError: Invalid status code: undefined at ServerResponse.writeHead (_http_server.js:194:11) at ServerResponse._implicitHeader (_httpserver.js:185:8) at write (_http_outgoing.js:632:9) at ServerResponse.end (_http_outgoing.js:751:5) at graphqlHandler.handle (/Users/nicholasivons/City/ctxfloods-backend/localServer.js:38:9) at setupRequestPgClientTransaction.default.then.then.catch.err (/Users/nicholasivons/City/ctxfloods-backend/handlers/graphqlHandler.js:67:15) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) (node:71646) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:71646) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. { JsonWebTokenError: invalid signature at Object.module.exports [as verify] (/Users/nicholasivons/City/ctxfloods-backend/node_modules/postgraphql/node_modules/jsonwebtoken/verify.js:107:17) at Object. (/Users/nicholasivons/City/ctxfloods-backend/node_modules/postgraphql/build/postgraphql/http/setupRequestPgClientTransaction.js:37:45) at step (/Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:133:27) at Object.next (/Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:114:57) at /Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:107:75 at new Promise () at Object.awaiter (/Users/nicholasivons/City/ctxfloods-backend/node_modules/tslib/tslib.js:103:16) at Object.setupRequestPgClientTransaction [as default] (/Users/nicholasivons/City/ctxfloods-backend/node_modules/postgraphql/build/postgraphql/http/setupRequestPgClientTransaction.js:20:20) at pgClient.query.then (/Users/nicholasivons/City/ctxfloods-backend/handlers/graphqlHandler.js:42:21) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) name: 'JsonWebTokenError', message: 'invalid signature', statusCode: 403 } (node:71646) UnhandledPromiseRejectionWarning: RangeError: Invalid status code: undefined at ServerResponse.writeHead (_http_server.js:194:11) at ServerResponse._implicitHeader (_httpserver.js:185:8) at write (_http_outgoing.js:632:9) at ServerResponse.end (_http_outgoing.js:751:5) at graphqlHandler.handle (/Users/nicholasivons/City/ctxfloods-backend/localServer.js:38:9) at setupRequestPgClientTransaction.default.then.then.catch.err (/Users/nicholasivons/City/ctxfloods-backend/handlers/graphqlHandler.js:67:15) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) (node:71646) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

Niicck commented 6 years ago

Refreshing the reset password page with an invalid token will also cause strange glitches. After refreshing and creating a new password, both the login screen and the map will be displayed on the same page.

Niicck commented 6 years ago

resolved by #379