Hi Everyone,
I’m working on automating the management of inactive users in my Auth0 tenant.
Here’s my setup:
- Blocking Users for Inactivity: I have a script that runs periodically to block users who haven’t logged in for more than 90 days. This script uses the Auth0 Management API to block the users. Here’s an overview of the process:
- Fetch all users who haven’t logged in for 90+ days.
- Block them using the
/api/v2/users/{id}
endpoint. The blocking part is working fine, and users are blocked after the inactivity threshold.
- Unblocking Users on Login Attempt: Now, I want to unblock these users automatically when they try to log in again. I tried adding an “Auth0 Action” under the “Post-Login” flow with a script that checks if the user is blocked and then calls the Management API to unblock the user. But it doesn’t work as expected as blocked users are unable to authenticate.
what would be the best approach to handle this scenario where users should be unblocked upon a login attempt after being blocked for inactivity?
Any advice or recommendations would be greatly appreciated! Thanks in advance.