Here we use redis to store the token
redis key design
access_token_{token}:{userInfoJsonStr}
After the user logs in successfully, the token is used as the key, and the user information is used as the value. Function: userinfo can be found through token
token_by_userId_{userId}:{token}
After the user logs in successfully, the user id is used as the key, and the token is used as the value: function: the token can be found through the userid
Note: the expiration time of the two keys is the same
When the code logic
user login authentication, through token_by_userId_{userId}, check whether the key exists in redis, if it exists, it means that the user has logged in. According to the found token, delete access_token_{token}, and then go to the login operation. (This process deletes the last login information, and the last login account will be offline.)