Relative Content

Tag Archive for node.jsjwt

Project for a course, Node, need jwt tokens assistance

I ask of you to not judge my programming because im a begginer, i have a question regarding the verification of jwt tokens in my web app.
I have a authRoutes.js file that covers registering and logging in to the server. It works ok and succesfully adds a user to the database and pulls the info when logging in. However when logging in a jwt token is generated that contains user id and the type of user (user or administrator). In my authMiddleware.js when i try to decode the token something goes wrong. I concluded this while testing with postman trying to add a restourant to the database, which only the administrator can do(thats why i do the authentication via token). I will give code for some files and if someone can help me i would be very grateful.