move reCaptcha keys into settings
This commit is contained in:
@@ -159,7 +159,7 @@
|
||||
</div>
|
||||
<textarea class="form-control" id="comments" name="comments" placeholder="Message - Tin nhắn" required rows="5"></textarea>
|
||||
<br>
|
||||
<div class="g-recaptcha" data-sitekey="6LeDvVUgAAAAAOqD_-h93kd5aW8CmpeVvKYu-m0p" data-callback='recaptchaCallback'></div>
|
||||
<div class="g-recaptcha" data-sitekey="{{ site_key }}" data-callback='recaptchaCallback'></div>
|
||||
<input type="hidden" id="response" name="response" value="" />
|
||||
<br>
|
||||
<button class="btn btn-primary hidden" id="btnSubmit" type="submit" name="form.submitted">Envoyer</button>
|
||||
|
||||
@@ -53,7 +53,7 @@ def home(request):
|
||||
response = request.params['response']
|
||||
|
||||
# verification reCaptcha ?
|
||||
ok, erreur = captcha_verify(response, request.remote_addr)
|
||||
ok, erreur = captcha_validate(response, request.remote_addr, request.registry.settings['secret_key'])
|
||||
if ok and comments != '':
|
||||
# no, message is not spam, send it
|
||||
body = """
|
||||
@@ -72,7 +72,7 @@ webmaster@meditation-sunyata.paris
|
||||
""".format(name, email, comments)
|
||||
|
||||
message = Message(subject="[MSParis] Message de contact",
|
||||
sender=request.registry.settings['cao_blogr.admin_email'],
|
||||
sender=request.registry.settings['admin_email'],
|
||||
body=body)
|
||||
message.add_recipient('phuoc@caotek.fr')
|
||||
mailer = request.registry['mailer']
|
||||
@@ -87,12 +87,13 @@ webmaster@meditation-sunyata.paris
|
||||
'name': name,
|
||||
'email': email,
|
||||
'comments': comments,
|
||||
'site_key' : request.registry.settings['site_key'],
|
||||
}
|
||||
|
||||
def captcha_verify(response, remote_addr):
|
||||
def captcha_validate(response, remote_addr, secret):
|
||||
VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'
|
||||
data = {
|
||||
'secret': '6LeDvVUgAAAAAGASZXCmcmhh-KtBWTZjXpLpKdNt',
|
||||
'secret': secret,
|
||||
'response': response,
|
||||
'remoteip': remote_addr,
|
||||
}
|
||||
|
||||
@@ -18,11 +18,15 @@ sqlalchemy.url = sqlite:///%(here)s/cao_blogr.sqlite
|
||||
# images location
|
||||
images_dir = /pyramid10/cao_sunyata/cao_blogr/static/img/
|
||||
|
||||
# reCaptcha keys
|
||||
site_key = 6LeDvVUgAAAAAOqD_-h93kd5aW8CmpeVvKYu-m0p
|
||||
secret_key = 6LeDvVUgAAAAAGASZXCmcmhh-KtBWTZjXpLpKdNt
|
||||
|
||||
# Mailer configuration
|
||||
# cao_blogr.admin_email = cao.thien-phuoc@orange.fr
|
||||
# mail.host = smtp.orange.fr
|
||||
# mail.port = 25
|
||||
cao_blogr.admin_email = phuoc@caotek.fr
|
||||
admin_email = phuoc@caotek.fr
|
||||
mail.host = smtp.gmail.com
|
||||
mail.port = 465
|
||||
mail.ssl = True
|
||||
|
||||
@@ -19,7 +19,7 @@ images_dir = /pyramid10/cao_sunyata/cao_blogr/static/img/
|
||||
# Mailer configuration
|
||||
# mail.host = localhost
|
||||
# mail.port = 25
|
||||
cao_blogr.admin_email = phuoc@caotek.fr
|
||||
admin_email = phuoc@caotek.fr
|
||||
mail.host = smtp.gmail.com
|
||||
mail.port = 465
|
||||
mail.ssl = True
|
||||
|
||||
Reference in New Issue
Block a user