0

I'm trying to create a realtime function that if the user's token is expired they would be logout automatically. I tried logging out the user if I got a 401 status code but sometimes I do receive an error using that and I'm also be using socket-io on my the project cause I need to display data in real time.

I uploaded the sample project on github and so far this is what I've done. It contains just the login/register/logout function

I also found this how-do-i-check-for-token-expiration-and-logout-user but I don't know how to wrap the function on applymiddleware.

And one last thing why am I getting 24 vulnerabilities (8 moderate, 15 high, 1 critical) on npm audit. I'm using node v14.18.0 for this project

Nellartsa
  • 29
  • 1
  • 7
  • where do you save your token? – bill.gates Oct 11 '21 at 10:42
  • Looks like you have used create-react-app, so you are going to build the final source code and serve your app as static pages. Therefore you do not need to worry about most of the vulnerabilities, as you are not going to deploy those packages. I would still recommend that you check the extra packages you added yourself. – hazimdikenli Oct 11 '21 at 10:49
  • @Ifaruki I store then on localstorage – Nellartsa Oct 11 '21 at 12:03
  • @hazimdikenli should I make react from scratch? Those vulnerabilities was already showing before I install other packages – Nellartsa Oct 11 '21 at 12:05
  • @Nellartsa well why dont you store them in cookies? they have an expire date. you set the expire date same like your token expiration. – bill.gates Oct 11 '21 at 13:12
  • @Ifaruki I'm not really familiar using cookie, but I'll try creating one using cookie hopefully I could make it work – Nellartsa Oct 12 '21 at 00:26

0 Answers0