本文整理汇总了Python中mygpo.users.models.User.get_user_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_user_by_email方法的具体用法?Python User.get_user_by_email怎么用?Python User.get_user_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygpo.users.models.User
的用法示例。
在下文中一共展示了User.get_user_by_email方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user_by_email [as 别名]
def post(self, request):
username = request.POST.get('username')
email = request.POST.get('email')
if not (username or email):
messages.error(request,
_('Provide either username or email address'))
return HttpResponseRedirect(reverse('admin-activate-user'))
user = None
if username:
user = User.get_user(username, is_active=None)
if email and not user:
user = User.get_user_by_email(email, is_active=None)
if not user:
messages.error(request, _('No user found'))
return HttpResponseRedirect(reverse('admin-activate-user'))
activate_user(user)
messages.success(request,
_('User {username} ({email}) activated'.format(
username=user.username, email=user.email)))
return HttpResponseRedirect(reverse('admin-activate-user'))
示例2: authenticate
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user_by_email [as 别名]
def authenticate(self, username=None, password=None):
if email_re.search(username):
user = User.get_user_by_email(username)
if not user:
return None
return user if user.check_password(password) else None
return None
示例3: get_user
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user_by_email [as 别名]
def get_user(username, email, is_active=None):
if username:
return User.get_user(username, is_active=None)
elif email:
return User.get_user_by_email(email, is_active=None)
return None
示例4: authenticate
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user_by_email [as 别名]
def authenticate(self, username=None, password=None):
try:
validate_email(username)
user = User.get_user_by_email(username)
if not user:
return None
return user if user.check_password(password) else None
except ValidationError:
return None
示例5: auth
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get_user_by_email [as 别名]
def auth(emailaddr, password):
if emailaddr is None or password is None:
return None
user = User.get_user_by_email(emailaddr)
if not user:
return None
if not user.check_password(password):
return None
if not user.is_active:
return None
return user