

Before any of the above code, an error was thrown but when everything is wired up correctly, I see the text in the second part of the if statement. To test this I temporarily add the following block of HTML to the index.html page. This is similar to the way that both Bootstrap and SqlAlchemy plug-ins were added to the application. The last step of including this plug-in is to initialise it with the application within the create_app function. None of the pages have flagged as requiring authentication yet, so this will not break anything at the moment.

Note that this points to a controller function called login in the Blueprint web that has not been created yet.
Flask blueprint authentication install#
Install and Configureįirst we must install the plug-in with pip install flask-login and then add it to the estimator module _init_ file so that it can be initialised with the create_app function.įirst import the manager class: from flask_login import LoginManager This is stored in the user session, but abstracts us away from worrying about the implementation. For now, I will just extend the existing functionality of the Anonymous Agile Estimator to use this extension.įlask-Login provides management of the user sessions, making a current_user available in the model used by the template and views. I am going to postpone deciding what the implementation will be. This post will introduce that concept.įlask-Login is able to work with any number of authentication schemes. Flask provides an extension to manage the user, tracking whether a person has been authenticated within the session.
