The use case that prompted me to do this was that in case that we need to reset passwords, and only allow users to continue interacting with the site when they finally update their password, in case it’s compromised. I’m looking for a way to redirect users that has a specific condition in their user model so that they only can change their password before interacting with the site.
I’m looking at two things:
- Clear such condition when the user changes their password. I have ideas of how to do this with signals.
- A conditional redirect for authenticated users that have the “force password reset” condition.
Other than decorating all my views, I don’t see a straightforward way that I can do this. Do I need to add some kind of middleware that extends the AuthenticationMiddleware?