本文整理汇总了Python中acct_mgr.api.AccountManager.email_verified方法的典型用法代码示例。如果您正苦于以下问题:Python AccountManager.email_verified方法的具体用法?Python AccountManager.email_verified怎么用?Python AccountManager.email_verified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类acct_mgr.api.AccountManager
的用法示例。
在下文中一共展示了AccountManager.email_verified方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComponentPermissionsPolicy
# 需要导入模块: from acct_mgr.api import AccountManager [as 别名]
# 或者: from acct_mgr.api.AccountManager import email_verified [as 别名]
class ComponentPermissionsPolicy(Component):
"""
This component provides permissions based on ticket components for Trac.
"""
implements(IPermissionRequestor, IPermissionPolicy, IRequestFilter)
ticket_field_name = Option('component-permissions', 'ticket_field_name', '',
"""The name of the field which should be checked to see if the component permission is required.
If not defined or empty, component permission is always required.""")
allow_reporter = BoolOption('component-permissions', 'allow_reporter', 'false',
""""Whether the reporter of a ticket should have access to that ticket even if
they do not have COMPONENT_VIEW or COMPONENT_*_VIEW privileges.""")
allow_cc = BoolOption('component-permissions', 'allow_cc', 'false',
"""Whether users listed in the cc field of a ticket should have access to that ticket even
if they do not have COMPONENT_VIEW or COMPONENT_*_VIEW privileges.""")
allow_owner = BoolOption('component-permissions', 'allow_owner', 'false',
"""Whether the owner of a ticket should have access to that ticket even if
they do not have COMPONENT_VIEW or COMPONENT_*_VIEW privileges.""")
allow_cc_email = BoolOption('component-permissions', 'allow_cc_email', 'false',
"""Whether users with their e-mail listed in the cc field of a ticket should have access to
that ticket even if they do not have COMPONENT_VIEW or COMPONENT_*_VIEW privileges. Make sure
e-mail is verified and cannot be freely changed.""")
hide_components = BoolOption('component-permissions', 'hide_components', 'false',
"""Whether components the user does not have permissions for should be hidden.""")
def __init__(self):
self.account_manager = None
try:
from acct_mgr.api import AccountManager
self.account_manager = AccountManager(self.env)
except ImportError:
pass
# IPermissionRequestor methods
def _get_permission_name(self, component):
name = re.sub('[^a-zA-Z0-9]+', '_', component).strip('_').upper()
if name:
return 'COMPONENT_%s_VIEW' % (name,)
else:
return None
def _get_email(self, username):
cnx = self.env.get_db_cnx()
cursor = cnx.cursor()
cursor.execute("""SELECT DISTINCT e.value FROM session AS s LEFT JOIN session_attribute AS e
ON (e.sid=s.sid AND e.authenticated=1 AND e.name = 'email')
WHERE s.authenticated=1 AND s.sid=%s""", (username,))
for email, in cursor:
return email
return None
def _get_bypass(self, ticket, username):
if not username or username == 'anonymous':
return False
if self.allow_owner and ticket['owner'] == username:
return True
if self.allow_reporter and ticket['reporter'] == username:
return True
if not self.allow_cc and not self.allow_cc_email:
return False
cc_list = [user for user in NotifyEmail.addrsep_re.split(ticket['cc']) if user]
if self.allow_cc and username in cc_list:
return True
if self.allow_cc_email:
email = self._get_email(username)
if email and email in cc_list:
if self.account_manager:
if self.account_manager.email_verified(username, email):
return True
else:
return True
return False
def get_permission_actions(self):
"""Return a list of actions defined by this component."""
permissions = ['COMPONENT_VIEW']
for component in model.Component.select(self.env):
permission = self._get_permission_name(component.name)
if permission:
permissions.append(permission)
return permissions
# IPermissionPolicy methods
def check_permission(self, action, username, resource, perm):
#.........这里部分代码省略.........