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

__init__ should pass login_manager instance to init_app? #13

Closed
SleeplessAnnoyedNerd opened this issue May 25, 2014 · 0 comments
Closed

Comments

@SleeplessAnnoyedNerd
Copy link

I think it is necessary to pass the login_manager to init_app in __init__ otherwise a new login_manager instance will be created in init_app. Which causes @login_required to return 401 instead of redirecting to Google. (Since context processor is assigned to the wrong login_manager instance.)

def __init__(self, app=None, login_manager=None):
    if login_manager:
        self.login_manager = login_manager
    else:
        self.login_manager = LoginManager()

    if app:
        self._app = app
        self.init_app(app, login_manager=self.login_manager)  # <=  pass current login_manager instance

I stumbled onto this as I tried following snippet from the documentation:

from flask_login import LoginManager
login_manager = LoginManager()
login_manager.init_app(app)
googlelogin = GoogleLogin(app, login_manager)
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