I'm building a Web App with Python / Flask. I'm protecting a view with the @login_required decorator. If user is not logged in it will redirect to my 'login' view URL, and add a flash message with ("You need to be logged in to view this page."). This flash message is then displayed after the redirected view ('login') is loaded. How can I add a category to this message since it looks its coming from @login_required?
Here is my view function:
@app.route('/')
@app.route('/index')
# This is the decorator that redirects my request to the
# 'login' view, and adds a flash message.
@login_required
#
def index():
...
return render_template(...)
In order to pass a category to a flash message I add "manually" I can do as follows.
flash_message = flash("User needs to be logged in to view this page", "category")