Solution
# The Home page is accessible to anyone
@app.route('/')
def home_page():
# The Members page is only accessible to authenticated users
@app.route('/members')
@login_required # Use of @login_required decorator
def member_page():
# The Admin page requires an 'Admin' role.
@app.route('/admin')
@roles_required('Admin') # Use of @roles_required decorator
def admin_page():
@admin_blueprint.route('/admin/teacher_or_admin')
@roles_required(['admin', 'teacher']) # requires admin OR teacher role
def admin_teacher_or_admin():
return "You have the right roles to access this page - it requires admin OR teacher roles"
@admin_blueprint.route('/admin/teacher_and_admin')
@roles_required('admin','teacher') # requires admin AND teacher roles
def admin_teacher_and_admin():
return "You have the right roles to access this view"
@admin_blueprint.route('/admin/student')
@roles_required('student')
def admin_student():
return "You have the right roles to access this page - requires student role"