Which of the following is a common mistake that would cause this role check to fail?
medium
A. Not importing the role_required decorator
B. Using @app.route after @role_required
C. Returning a string instead of JSON
D. Defining the function without parentheses
Solution
Step 1: Check decorator usage
role_required must be imported to work; missing import causes failure.
Step 2: Verify other options
@app.route order is flexible; returning string is valid; function definition syntax is correct.
Final Answer:
Not importing the role_required decorator -> Option A
Quick Check:
Missing import breaks decorator [OK]
Hint: Always import decorators before use [OK]
Common Mistakes:
Assuming decorator order always matters
Confusing return type with access control
Syntax errors in function definition
5. You want to create a Flask route /settings that only users with roles 'admin' or 'manager' can access. Which code snippet correctly implements this role-based access control?