本文整理匯總了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