Use jwt for login registration, how to verify and skip login for the second login after login?

1. After logging in for the first time, return to the front-end token, and then the front-end takes the token to get the corresponding data
2. When you log in for the second time, you don"t need to enter the account password again and jump directly to the corresponding page

.

the first thought is to use the storage user id to redis to get the token and then verify it again, but you must add a connection that does not require authentication, but I don"t think this is very good

app.use(jwtKoa({secret}).unless({
    path: [/^\/adduser/, /^\/login/] ///^\/product\/getToken/jwt
}))

the second one is based on the user"s id storage client token, and then takes the token to verify

Learning node+koa wants to write a small example to practice, but I don"t know how to write it. Please give me some advice

.
Apr.18,2021

  1. it's either a blacklist or a whitelist, depending on what you need (but I don't think you want to).
  2. if you are rendering on the client (you do not access the backend service), token can pass authentication by default (but you can also save your own information for front-end verification, such as timeout), and just jump to the corresponding page (in this case, you will also send a request to get the data. In this case, the backend verification token and permission are required). If you are server-side rendering (access to the back-end service), then directly verify which to jump.
Menu