def register(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
email=form.cleaned_data['email']
)
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
new_user = authenticate(username=username, password=password)
if new_user is not None:
if new_user.is_active:
stripe_actions.customers.create(user=new_user)
login(request, new_user)
return HttpResponseRedirect('/scan/default/')
else:
# this would be weird to get here
return HttpResponseRedirect('/register/success/')
else:
return HttpResponseRedirect('/register/success/')
else:
form = RegistrationForm()
return render(
request,
'registration/register.html',
{ 'form': form },
)
评论列表
文章目录