本文整理汇总了Python中pytas.http.TASClient.verify_user方法的典型用法代码示例。如果您正苦于以下问题:Python TASClient.verify_user方法的具体用法?Python TASClient.verify_user怎么用?Python TASClient.verify_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytas.http.TASClient
的用法示例。
在下文中一共展示了TASClient.verify_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: email_confirmation
# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import verify_user [as 别名]
def email_confirmation(request):
context = {}
if request.method == 'POST':
form = EmailConfirmationForm(request.POST)
if form.is_valid():
code = request.POST['code']
username = request.POST['username']
try:
tas = TASClient()
user = tas.get_user(username=username)
tas.verify_user(user['id'], code)
activate_local_user(username)
messages.success(request, 'Congratulations, your email has been verified! Please log in now.')
return HttpResponseRedirect(reverse('tas:profile'))
except Exception as e:
logger.exception('Email verification failed')
if e[0] == 'User not found':
form.add_error('username', e[1])
else:
form.add_error('code', 'Email verification failed. Please check your verification code and username and try again.')
else:
form = EmailConfirmationForm(initial={'code': request.GET.get('code', '')})
context['form'] = form
return render(request, 'tas/email_confirmation.html', context)
示例2: email_confirmation
# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import verify_user [as 别名]
def email_confirmation(request, code=None):
context = {}
if request.method == 'POST':
form = forms.EmailConfirmationForm(request.POST)
if form.is_valid():
data = form.cleaned_data
code = data['code']
username = data['username']
password = data['password']
try:
tas = TASClient()
user = tas.get_user(username=username)
if tas.verify_user(user['id'], code, password=password):
messages.success(request,
'Congratulations, your account has been activated! '
'You can now log in to DesignSafe.')
return HttpResponseRedirect(
reverse('designsafe_accounts:manage_profile'))
else:
messages.error(request,
'We were unable to activate your account. Please try '
'again. If this problem persists, please '
'<a href="/help">open a support ticket</a>.')
form = forms.EmailConfirmationForm(
initial={'code': code, 'username': username})
except:
logger.exception('TAS Account activation failed')
form.add_error('__all__',
'Account activation failed. Please confirm your '
'activation code, username and password and try '
'again.')
else:
if code is None:
code = request.GET.get('code', '')
form = forms.EmailConfirmationForm(initial={'code': code})
context['form'] = form
return render(request, 'designsafe/apps/accounts/email_confirmation.html', context)