本文整理汇总了Python中framework.auth.core.User.create_confirmed方法的典型用法代码示例。如果您正苦于以下问题:Python User.create_confirmed方法的具体用法?Python User.create_confirmed怎么用?Python User.create_confirmed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类framework.auth.core.User
的用法示例。
在下文中一共展示了User.create_confirmed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_or_create_user
# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import create_confirmed [as 别名]
def get_or_create_user(fullname, address, is_spam=False):
"""Get or create user by email address.
:param str fullname: User full name
:param str address: User email address
:param bool is_spam: User flagged as potential spam
:return: Tuple of (user, created)
"""
user = get_user(email=address)
if user:
return user, False
else:
password = str(uuid.uuid4())
user = User.create_confirmed(address, password, fullname)
user.verification_key = generate_verification_key()
if is_spam:
user.system_tags.append('is_spam')
return user, True
示例2: get_or_create_user
# 需要导入模块: from framework.auth.core import User [as 别名]
# 或者: from framework.auth.core.User import create_confirmed [as 别名]
def get_or_create_user(fullname, address, reset_password=True, is_spam=False):
"""
Get or create user by fullname and email address.
:param str fullname: user full name
:param str address: user email address
:param boolean reset_password: ask user to reset their password
:param bool is_spam: user flagged as potential spam
:return: tuple of (user, created)
"""
user = get_user(email=address)
if user:
return user, False
else:
password = str(uuid.uuid4())
user = User.create_confirmed(address, password, fullname)
if password:
user.verification_key_v2 = generate_verification_key(verification_type='password')
if is_spam:
user.system_tags.append('is_spam')
return user, True