Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential regression in expected behavior with UserMixin.is_authenticated defaulting to is_active that was changed in 0.6.0 #713

Open
nickjj opened this issue Oct 23, 2022 · 0 comments

Comments

@nickjj
Copy link
Contributor

nickjj commented Oct 23, 2022

Version 0.6.0 has:

Based on the comments in the above issues, the case for doing this was to prevent inactive users from logging in but an inactive user is not the same as a user who can't authenticate due to invalid credentials. These are much different things.

In 0.5.0 you could do:

    @login_manager.user_loader
    def load_user(uid):
        user = user_model.query.get(uid)

        if not user.is_active():
            login_manager.login_message = 'This account has been disabled.'
            return None

        return user

And then if an inactive user tried to login they would receive a custom flash message. This lets them know they have an account but they've been disabled.

With 0.6.0 this code path doesn't seem to execute because the user gets blocked before they would be loaded so you end up with whatever message you would send to the user when their authentication failed. This is a regression in behavior.

I thought a potential workaround in 0.6.0 would have been to add this to my user model (the default in 0.5.0):

    def is_authenticated(self):
        return True

But this had no effect. I'm still not able to execute the user loader that would have presented a custom flash message.

How can we get the old behavior back where end users of this library can handle inactive users after they've been authenticated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant