Which fix removes the bug?
if user.get('role') is 'admin':
grant()
- Compare by value:
== 'admin'instead - Compare by value:
in 'admin'instead - Change
.get('role')to['role'] - Wrap the value in
str()before the test
is compares object identity, which is unreliable for strings built at runtime.