https://supertokens.com/ logo
#general
Title
# general
a

andrew1123

05/11/2022, 2:15 PM
Hi, is there anyway to block a user for a period of time 🤔
r

rp

05/11/2022, 3:19 PM
hey @andrew1123
well, not in built to supertokens, but you can always modify that user's access token payload to indicate that they should be blocked until some expiry time. And then post session verification, you can check if that time has passed, if not, return an unauthorised error (non 401 status code), else let the API run. When you modify the access token's payload (in offline mode), it will take sometime to propogate that change to the user's session (depending on access token's lifetime). But if you want it to happen immediately, cache the fact that you changed the access token for that user and check for it in your APIs. When that user uses the app, and the API checks if their access token has been changed, then you can send a 401 to them forcing a session refresh. The session refresh will update their access token's payload to have the fact that they are blocked and they will loose access immediately.
a

andrew1123

05/11/2022, 4:12 PM
I see. Thanks for detailed explanation😁 @rp
3 Views