Verify CAPTCHA
parent
946b30b486
commit
9b3c970bba
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
class CaptchaVerifier
|
||||
{
|
||||
public function isVerified(string $solution, string $secret, string $sitekey)
|
||||
{
|
||||
$url = "https://api.friendlycaptcha.com/api/v1/siteverify";
|
||||
$data = array(
|
||||
'solution' => $solution,
|
||||
'secret'=> $secret,
|
||||
'sitekey'=> $sitekey,
|
||||
);
|
||||
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'content' => json_encode( $data ),
|
||||
'header'=> "Content-Type: application/json\r\n" .
|
||||
"Accept: application/json\r\n"
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create( $options );
|
||||
$result = file_get_contents( $url, false, $context );
|
||||
$response = json_decode( $result );
|
||||
|
||||
$isVerified = $response->success;
|
||||
|
||||
return $isVerified;
|
||||
}
|
||||
}
|
@ -1,32 +1,27 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Register{% endblock %}
|
||||
{% block title %}Register
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% for flashError in app.flashes('verify_email_error') %}
|
||||
<div class="alert alert-danger" role="alert">{{ flashError }}</div>
|
||||
{% endfor %}
|
||||
|
||||
<h1>Register</h1>
|
||||
|
||||
{{ form_start(registrationForm) }}
|
||||
{{ form_row(registrationForm.email) }}
|
||||
{{ form_row(registrationForm.username) }}
|
||||
{{ form_row(registrationForm.zipcode, {
|
||||
label: 'PLZ'
|
||||
}) }}
|
||||
{{ form_row(registrationForm.plainPassword, {
|
||||
label: 'Password'
|
||||
}) }}
|
||||
{{ form_row(registrationForm.agreeTerms) }}
|
||||
{% for flashError in app.flashes('verify_email_error') %}
|
||||
<div class="alert alert-danger" role="alert">{{ flashError }}</div>
|
||||
{% endfor %}
|
||||
{% for message in app.flashes('error') %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<h1>Register</h1>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-sm-2">CAPTCHA</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="frc-captcha" data-sitekey="FCMLGE739LB528NG"></div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-lg btn-primary">Register</button>
|
||||
{{ form_end(registrationForm) }}
|
||||
{{ form_start(registrationForm) }}
|
||||
{{ form_widget(registrationForm) }}
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-sm-2">CAPTCHA</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="frc-captcha" data-sitekey="FCMLGE739LB528NG" id="captcha"></div>
|
||||
</div>
|
||||
</div>
|
||||
{{ form_end(registrationForm) }}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue