mirror of
https://github.com/wassname/flask-security.git
synced 2026-06-27 16:10:11 +08:00
Changed has_role to accept strings with mongoengine. Fixes #110
This commit is contained in:
@@ -241,8 +241,7 @@ class RoleMixin(object):
|
||||
self.name == getattr(other, 'name', None))
|
||||
|
||||
def __ne__(self, other):
|
||||
return (self.name != other and
|
||||
self.name != getattr(other, 'name', None))
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
class UserMixin(BaseUserMixin):
|
||||
@@ -261,7 +260,10 @@ class UserMixin(BaseUserMixin):
|
||||
"""Returns `True` if the user identifies with the specified role.
|
||||
|
||||
:param role: A role name or `Role` instance"""
|
||||
return role in self.roles
|
||||
if isinstance(role, basestring):
|
||||
return role in (role.name for role in self.roles)
|
||||
else:
|
||||
return role in self.roles
|
||||
|
||||
|
||||
class AnonymousUser(AnonymousUserBase):
|
||||
|
||||
Reference in New Issue
Block a user