Complete the code to import the Flask-Login extension.
from flask_login import [1]
The LoginManager class is imported from flask_login to manage user sessions.
Complete the code to initialize the LoginManager with the Flask app.
login_manager = [1]()
login_manager.init_app(app)The LoginManager instance is created and linked to the Flask app to manage login sessions.
Fix the error in the user loader function decorator.
@login_manager.[1] def load_user(user_id): return User.get(user_id)
The correct decorator is @login_manager.user_loader to register the user loader callback.
Fill both blanks to protect a route so only logged-in users can access it.
@app.route('/dashboard') @[1] def dashboard(): return 'Welcome to your dashboard!'
The @login_required decorator restricts access to logged-in users only.
Fill all three blanks to log in a user after verifying credentials.
from flask_login import [1] @app.route('/login', methods=['POST']) def login(): user = User.query.filter_by(username=request.form['username']).first() if user and user.check_password(request.form['password']): [2](user) return redirect([3]) return 'Invalid credentials', 401
Import login_user to log in the user, call login_user(user), and redirect to the dashboard page.
