I have a login route like this
@app.route('/login/<int:user_id>)
def login(user_id):
if some_condition:
return redirect(url_for('dashboard', user_id=user_id)
return render_template('login.html')
The route for the dashboard goes like this
@app.route('/dashboard/<int:user_id>)
@login_required
def dashboard(user_id):
# some code...
return render_template('dashboard.html')
Ideally, you shouldn't be able to access the dashboard without logging in. Hence, the use of @login_required decorator. When a user manually types in the address bar /dashboard/2 where 2 represents the user_id. If the user is not logged in, dashboard redirects to login. The following line causes that behaviour.
login_manager.login_view = 'login'
login refers to the name of the login route function. How do i pass the user_id, in this case 2 to login_manager.login_view = 'login'