mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-10 07:16:06 -06:00
make captcha optional
This commit is contained in:
parent
efc1fc06ca
commit
ce0cfe4456
@ -5,6 +5,8 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% set enableCaptcha = setting_value('visiosoft.module.profile::google_captcha_site_key') and setting_value('visiosoft.module.profile::google_captcha_secret_key') %}
|
||||||
|
|
||||||
<div class="py-4">
|
<div class="py-4">
|
||||||
<div class="row justify-content-center bg-light rounded border px-3">
|
<div class="row justify-content-center bg-light rounded border px-3">
|
||||||
<div class="col-12 col-md-6 text-left p-3 m-0">
|
<div class="col-12 col-md-6 text-left p-3 m-0">
|
||||||
@ -20,7 +22,9 @@
|
|||||||
'url':form.options.url
|
'url':form.options.url
|
||||||
})|raw }}
|
})|raw }}
|
||||||
|
|
||||||
|
{% if enableCaptcha %}
|
||||||
<input type="hidden" name="recaptcha_token" id="recaptcha_token" class="recaptcha-token">
|
<input type="hidden" name="recaptcha_token" id="recaptcha_token" class="recaptcha-token">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% include 'visiosoft.theme.base::addons/anomaly/users-module/partials/register-form' %}
|
{% include 'visiosoft.theme.base::addons/anomaly/users-module/partials/register-form' %}
|
||||||
|
|
||||||
@ -51,7 +55,7 @@
|
|||||||
{{ form_close() }}
|
{{ form_close() }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ addBlock('register/corporate-register')|raw }}
|
{{ addBlock('register/corporate-register', {'enableCaptcha': enableCaptcha})|raw }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-6 py-3 pr-0 instructions d-none d-md-block">
|
<div class="col-12 col-md-6 py-3 pr-0 instructions d-none d-md-block">
|
||||||
@ -78,12 +82,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if enableCaptcha %}
|
||||||
{% set reCAPTCHASiteKey = setting_value('visiosoft.module.profile::google_captcha_site_key') %}
|
{% set reCAPTCHASiteKey = setting_value('visiosoft.module.profile::google_captcha_site_key') %}
|
||||||
<script>
|
<script>
|
||||||
let reCAPTCHASiteKey = "{{ reCAPTCHASiteKey }}"
|
let reCAPTCHASiteKey = "{{ reCAPTCHASiteKey }}"
|
||||||
</script>
|
</script>
|
||||||
{{ asset_add('scripts.js', asset_download('https://www.google.com/recaptcha/api.js?render=' ~ reCAPTCHASiteKey, 60*60*24)) }}
|
{{ asset_add('scripts.js', asset_download('https://www.google.com/recaptcha/api.js?render=' ~ reCAPTCHASiteKey, 60*60*24)) }}
|
||||||
{{ asset_add("scripts.js", "visiosoft.theme.base::js/register.js") }}
|
|
||||||
{{ asset_add("scripts.js", "visiosoft.module.profile::assets/js/captcha.js") }}
|
{{ asset_add("scripts.js", "visiosoft.module.profile::assets/js/captcha.js") }}
|
||||||
|
{% endif %}
|
||||||
|
{{ asset_add("scripts.js", "visiosoft.theme.base::js/register.js") }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,6 @@
|
|||||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Command\SetOptions;
|
use Visiosoft\ProfileModule\Profile\Register2\Command\SetOptions;
|
||||||
use Anomaly\UsersModule\User\UserModel;
|
use Anomaly\UsersModule\User\UserModel;
|
||||||
use Visiosoft\ProfileModule\Profile\Validation\ValidateRegister;
|
|
||||||
use Visiosoft\ProfileModule\Rules\ReCaptchaRule;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RegisterFormBuilder
|
* Class RegisterFormBuilder
|
||||||
@ -32,96 +30,6 @@ class Register2FormBuilder extends FormBuilder
|
|||||||
*/
|
*/
|
||||||
protected $model = UserModel::class;
|
protected $model = UserModel::class;
|
||||||
|
|
||||||
/**
|
|
||||||
* The form fields.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fields = [
|
|
||||||
'recaptcha_token' => [
|
|
||||||
'required' => true,
|
|
||||||
'type' => 'anomaly.field_type.text',
|
|
||||||
'config' => [
|
|
||||||
"max" => 0,
|
|
||||||
],
|
|
||||||
'rules' => [
|
|
||||||
'valid_recaptcha'
|
|
||||||
],
|
|
||||||
'validators' => [
|
|
||||||
'valid_recaptcha' => [
|
|
||||||
'message' => false,
|
|
||||||
'handler' => ReCaptchaRule::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'username' => [
|
|
||||||
'required' => true,
|
|
||||||
],
|
|
||||||
'first_name' => [
|
|
||||||
'instructions' => false,
|
|
||||||
'required' => true,
|
|
||||||
],
|
|
||||||
'last_name' => [
|
|
||||||
'instructions' => false,
|
|
||||||
'required' => true,
|
|
||||||
],
|
|
||||||
'phone' => [
|
|
||||||
'type' => 'anomaly.field_type.text',
|
|
||||||
'required' => true,
|
|
||||||
'rules' => [
|
|
||||||
'valid_register',
|
|
||||||
],
|
|
||||||
'validators' => [
|
|
||||||
'valid_register' => [
|
|
||||||
'message' => false,
|
|
||||||
'handler' => ValidateRegister::class,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'email' => [
|
|
||||||
'instructions' => false,
|
|
||||||
],
|
|
||||||
'password' => [
|
|
||||||
'instructions' => false,
|
|
||||||
],
|
|
||||||
"accept_terms" => [
|
|
||||||
"type" => "anomaly.field_type.boolean",
|
|
||||||
"required" => true,
|
|
||||||
"config" => [
|
|
||||||
"default_value" => false,
|
|
||||||
"mode" => "checkbox",
|
|
||||||
"label" => 'visiosoft.module.profile::field.accept_terms_label',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"accept_protection_law" => [
|
|
||||||
"type" => "anomaly.field_type.boolean",
|
|
||||||
"required" => true,
|
|
||||||
"config" => [
|
|
||||||
"default_value" => false,
|
|
||||||
"mode" => "checkbox",
|
|
||||||
"label" => 'visiosoft.module.profile::field.accept_protection_law_label',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"accept_privacy_terms" => [
|
|
||||||
"type" => "anomaly.field_type.boolean",
|
|
||||||
"required" => true,
|
|
||||||
"config" => [
|
|
||||||
"default_value" => false,
|
|
||||||
"mode" => "checkbox",
|
|
||||||
"label" => 'visiosoft.module.profile::field.accept_privacy_terms_label',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"receive_sms_emails" => [
|
|
||||||
"type" => "anomaly.field_type.boolean",
|
|
||||||
"required" => true,
|
|
||||||
"config" => [
|
|
||||||
"default_value" => false,
|
|
||||||
"mode" => "checkbox",
|
|
||||||
"label" => 'visiosoft.module.profile::field.receive_sms_emails_label',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The form actions.
|
* The form actions.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -0,0 +1,109 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile\Register2;
|
||||||
|
|
||||||
|
use Visiosoft\ProfileModule\Profile\Validation\ValidateRegister;
|
||||||
|
use Visiosoft\ProfileModule\Rules\ReCaptchaRule;
|
||||||
|
|
||||||
|
class Register2FormFields
|
||||||
|
{
|
||||||
|
public function handle(Register2FormBuilder $builder)
|
||||||
|
{
|
||||||
|
$captchaSiteKey = setting_value('visiosoft.module.profile::google_captcha_site_key');
|
||||||
|
$captchaSecretKey = setting_value('visiosoft.module.profile::google_captcha_secret_key');
|
||||||
|
|
||||||
|
$register = [];
|
||||||
|
if ($captchaSiteKey && $captchaSecretKey) {
|
||||||
|
$register = [
|
||||||
|
'recaptcha_token' => [
|
||||||
|
'required' => true,
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
|
'config' => [
|
||||||
|
"max" => 0,
|
||||||
|
],
|
||||||
|
'rules' => [
|
||||||
|
'valid_recaptcha'
|
||||||
|
],
|
||||||
|
'validators' => [
|
||||||
|
'valid_recaptcha' => [
|
||||||
|
'message' => false,
|
||||||
|
'handler' => ReCaptchaRule::class
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->setFields(
|
||||||
|
array_merge(
|
||||||
|
$register,
|
||||||
|
[
|
||||||
|
'username' => [
|
||||||
|
'required' => true,
|
||||||
|
],
|
||||||
|
'first_name' => [
|
||||||
|
'instructions' => false,
|
||||||
|
'required' => true,
|
||||||
|
],
|
||||||
|
'last_name' => [
|
||||||
|
'instructions' => false,
|
||||||
|
'required' => true,
|
||||||
|
],
|
||||||
|
'phone' => [
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
|
'required' => true,
|
||||||
|
'rules' => [
|
||||||
|
'valid_register',
|
||||||
|
],
|
||||||
|
'validators' => [
|
||||||
|
'valid_register' => [
|
||||||
|
'message' => false,
|
||||||
|
'handler' => ValidateRegister::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'email' => [
|
||||||
|
'instructions' => false,
|
||||||
|
],
|
||||||
|
'password' => [
|
||||||
|
'instructions' => false,
|
||||||
|
],
|
||||||
|
"accept_terms" => [
|
||||||
|
"type" => "anomaly.field_type.boolean",
|
||||||
|
"required" => true,
|
||||||
|
"config" => [
|
||||||
|
"default_value" => false,
|
||||||
|
"mode" => "checkbox",
|
||||||
|
"label" => 'visiosoft.module.profile::field.accept_terms_label',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"accept_protection_law" => [
|
||||||
|
"type" => "anomaly.field_type.boolean",
|
||||||
|
"required" => true,
|
||||||
|
"config" => [
|
||||||
|
"default_value" => false,
|
||||||
|
"mode" => "checkbox",
|
||||||
|
"label" => 'visiosoft.module.profile::field.accept_protection_law_label',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"accept_privacy_terms" => [
|
||||||
|
"type" => "anomaly.field_type.boolean",
|
||||||
|
"required" => true,
|
||||||
|
"config" => [
|
||||||
|
"default_value" => false,
|
||||||
|
"mode" => "checkbox",
|
||||||
|
"label" => 'visiosoft.module.profile::field.accept_privacy_terms_label',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"receive_sms_emails" => [
|
||||||
|
"type" => "anomaly.field_type.boolean",
|
||||||
|
"required" => true,
|
||||||
|
"config" => [
|
||||||
|
"default_value" => false,
|
||||||
|
"mode" => "checkbox",
|
||||||
|
"label" => 'visiosoft.module.profile::field.receive_sms_emails_label',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user