本文整理汇总了Python中social.apps.django_app.default.models.UserSocialAuth.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python UserSocialAuth.create_user方法的具体用法?Python UserSocialAuth.create_user怎么用?Python UserSocialAuth.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类social.apps.django_app.default.models.UserSocialAuth
的用法示例。
在下文中一共展示了UserSocialAuth.create_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_user [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args, **kwargs):
"""
Creates user. Depends on get_username pipeline.
"""
if user:
return {'user': user}
if not username:
return None
email = details.get('email')
original_email = None
# email is required
if not email:
message = _("""your social account needs to have a verified email address in order to proceed.""")
raise AuthFailed(backend, message)
# Avoid hitting field max length
if email and len(email) > 75:
original_email = email
email = ''
return {
'user': UserSocialAuth.create_user(username=username,
email=email,
sync_emailaddress=False),
'original_email': original_email,
'is_new': True
}
示例2: create_user
# 需要导入模块: from social.apps.django_app.default.models import UserSocialAuth [as 别名]
# 或者: from social.apps.django_app.default.models.UserSocialAuth import create_user [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args,
**kwargs):
"""Create user. Depends on get_username pipeline."""
if user:
return {'user': user}
if not username:
return None
user = UserSocialAuth.create_user(username=get_unique_username(), )
permission = Permission.objects.get(codename=u'is_requester')
user.user_permissions.add(permission)
profile = Profile.objects.create(user=user)
user.set_username_by_id()
user.save()
return {
'user': user,
'is_new': True
}