def unlock(request, email):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = UnlockForm(request.POST)
# check whether it's valid:
if form.is_valid():
try:
user = User.objects.get(email=email)
user.unlock()
if not user.dyn:
context = {'token': user.get_token()}
send_token_email(context, user)
except User.DoesNotExist:
pass # fail silently, otherwise people can find out if email addresses are registered with us
return HttpResponseRedirect(reverse('unlock/done'))
# if a GET (or any other method) we'll create a blank form
else:
form = UnlockForm()
return render(request, 'unlock.html', {'form': form})
评论列表
文章目录