S
S
Sport-code2019-03-17 12:36:36
JSON Web Token
Sport-code, 2019-03-17 12:36:36

How to detect idle time in JWT token?

Hello!
I would also like to know if there is such an opportunity in the JWT token to determine the idle time?
Those. set the JWT token time for example 15 min. - this is not the total time that passes
and after 15 minutes the token is closed, but that the countdown starts when a person has been inactive on the site for 20 minutes,
and the entire token has been deleted and his account has closed.
It turns out that if a person works on the site for 30 minutes, and the token is set for 15 minutes so that the account does not close,
and when he left for 20 minutes. and for wanting to continue working, the account would be closed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2019-03-17
@Sport-code

const jwt = {
  payload: {
    idle: 900000 // 15min * 60s * 1000ms
  }
}

setInterval(() => {
  user.logout()
}, jwt.payload.idle)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question