Unverified Commit 994b56cf authored by Johannes Tomren Røsvik's avatar Johannes Tomren Røsvik
Browse files

Update captcha to values for testing

parent 973475f9
Pipeline #76860 passed with stage
in 1 minute and 10 seconds
......@@ -23,7 +23,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '$n%^#g%qx#82w6t^dvjqwv)q*1cy+fwh1ohku7-rbjqcei2^jr'
RECAPTCHA_KEY = '6Ld1AN8UAAAAAGENA-uPsuCVBPydoONxPjGip2fO'
RECAPTCHA_SECRET_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
RECAPTCHA_SITE_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
ADMINS = [('APU', 'tdt4242apu@gmail.com')]
......
......@@ -10,7 +10,7 @@
{% csrf_token %}
{% bootstrap_form form %}
<div class="form-group">
<div class="g-recaptcha" data-sitekey="6Ld1AN8UAAAAALCLQJZdnam9MmRaB7Smulf0E5F1"></div>
<div class="g-recaptcha" data-sitekey="{{ captcha_sitekey }}"></div>
</div>
<button type="submit">Sign up</button>
</form>
......
......@@ -31,7 +31,7 @@ class SignUpTest(TestCase):
def test_verify_recaptcha(self):
agreelance.settings.RECAPTCHA_KEY = "6Ld1AN8UAAAAAGENA-uPsuCVBPydoONxPjGip2fO"
agreelance.settings.RECAPTCHA_SECRET_KEY = "6Ld1AN8UAAAAAGENA-uPsuCVBPydoONxPjGip2fO"
old_captcha_response = self.filled_form.get('g-recaptcha-response')
expected_result = {
......@@ -44,7 +44,7 @@ class SignUpTest(TestCase):
def test_signup(self):
agreelance.settings.RECAPTCHA_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
agreelance.settings.RECAPTCHA_SECRET_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
# https://stackoverflow.com/a/25835403
rf = RequestFactory()
......
......@@ -4,14 +4,17 @@ from django.contrib.auth import login, authenticate
from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib import messages
from django.conf import settings
import urllib
import json
import os
import agreelance.settings
from .forms import SignUpForm
SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'
RECAPTCHA_RESPONSE_PARAM = 'g-recaptcha-response'
RECAPTCHA_SITE_KEY = settings.RECAPTCHA_SITE_KEY
def index(request):
return render(request, 'base.html')
......@@ -45,12 +48,17 @@ def signup(request):
return redirect('home')
else:
form = SignUpForm()
return render(request, 'user/signup.html', {'form': form})
return render(
request,
'user/signup.html',
{'form': form, 'captcha_sitekey': RECAPTCHA_SITE_KEY}
)
def verify_recaptcha(recaptcha_response):
url = SITE_VERIFY_URL
values = {
'secret': agreelance.settings.RECAPTCHA_KEY,
'secret': agreelance.settings.RECAPTCHA_SECRET_KEY,
'response': recaptcha_response
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment