示例#1
0
def signup(request):
    if is_ip_banned(request):
        messages.error(request, "Your account was disabled.")
        return redirect('home')

    if request.method == 'POST':
        captcha = CaptchaQuestion.objects.get(
            id=request.session.get('captcha_id'))

        form = UserSignupForm(request.POST, captcha=captcha)
        if form.is_valid():
            form.save()
            user = authenticate(
                username=form.cleaned_data['username'],
                password=form.cleaned_data['password1'],
            )
            login(request, user)
            messages.success(request, 'Account created')
            return redirect('home')
    else:
        captcha = CaptchaQuestion.objects.order_by('?')[0]
        request.session['captcha_id'] = captcha.id
        form = UserSignupForm(captcha=captcha)
    return render(request, 'accounts/signup.html', {
        'form': form,
    })
示例#2
0
def signup(request):
	if is_ip_banned(request):
		messages.error(request, "Your account was disabled.")
		return redirect('home')

	if request.method == 'POST':
		captcha = CaptchaQuestion.objects.get(id=request.session.get('captcha_id'))

		form = UserSignupForm(request.POST, captcha=captcha)
		if form.is_valid():
			form.save()
			user = authenticate(
				username=form.cleaned_data['username'],
				password=form.cleaned_data['password1'],
			)
			login(request, user)
			messages.success(request, 'Account created')
			return redirect('home')
	else:
		captcha = CaptchaQuestion.objects.order_by('?')[0]
		request.session['captcha_id'] = captcha.id
		form = UserSignupForm(captcha=captcha)
	return render(request, 'accounts/signup.html', {
		'form': form,
	})
示例#3
0
def read_only_mode(request):
    return {
        'site_is_writeable': settings.SITE_IS_WRITEABLE,
        'is_ip_banned': is_ip_banned(request),
    }
示例#4
0
def read_only_mode(request):
	return {
		'site_is_writeable': settings.SITE_IS_WRITEABLE,
		'is_ip_banned': is_ip_banned(request),
	}
示例#5
0
 def dispatch(self, request, *args, **kwargs):
     if is_ip_banned(request):
         messages.error(request, "Your account was disabled.")
         return redirect('home')
     else:
         return super().dispatch(request, *args, **kwargs)
示例#6
0
def custom_login(request):
    if is_ip_banned(request):
        messages.error(request, "Your account was disabled.")
        return redirect('home')
    else:
        return base_login(request)
示例#7
0
def custom_login(request):
	if is_ip_banned(request):
		messages.error(request, "Your account was disabled.")
		return redirect('home')
	else:
		return base_login(request)