Add a captcha on subscription

Complete the documentation
Disable (for now) timestamps in Account
This commit is contained in:
Timothée Jaussoin 2020-04-22 15:24:12 +02:00
parent 641feb9a2e
commit 8fd7e8adbf
9 changed files with 104 additions and 6 deletions

View file

@ -34,3 +34,6 @@ OVH_APP_KEY=
OVH_APP_SECRET=
OVH_APP_ENDPOINT=ovh-eu
OVH_APP_CONSUMER_KEY=
NOCAPTCHA_SECRET=secret-key
NOCAPTCHA_SITEKEY=site-key

View file

@ -19,6 +19,27 @@ You can also run the test suit using `phpunit`.
To know more about the web server configuration part, you can directly [visit the official Laravel installation documentation](https://laravel.com/docs/6.x).
### Configure the .env file
Complete all the other variables in the `.env` file:
- The OVH SMS connector
- SMTP configuration
- App name, SIP domain…
### SELinux
If you are running on a CentOS/RedHat machine, please ensure that SELinux is correctly configured.
Allow the webserver user to write in the `storage/` directory:
chcon -R -t httpd_sys_rw_content_t storage/
If your external database is locate on a remote machine, you should also allow your webserver user to connect to remote hosts:
semanage port -a -t http_port_t -p tcp 3306 // Open remote connections on the MySQL port for example
setsebool httpd_can_network_connect 1 // Allow remote network connected
setsebool httpd_can_network_connect_db 1 // Allow remote database connection
### CRON job
The DIGEST authentication method is saving some temporary information (nonces) in the database.

View file

@ -27,6 +27,7 @@ class Account extends Authenticatable
protected $connection = 'external';
protected $with = ['passwords'];
protected $dates = ['creation_time'];
public $timestamps = false;
public function passwords()
{

View file

@ -42,6 +42,7 @@ class AccountController extends Controller
$request->validate([
'username' => 'required|unique:external.accounts,username|min:6',
'phone' => 'required_without:email|nullable|unique:external.aliases,alias|unique:external.accounts,username|starts_with:+|phone:AUTO',
'g-recaptcha-response' => 'required|captcha',
'email' => 'required_without:phone|nullable|email|confirmed'
]);

View file

@ -9,6 +9,7 @@
"license": "MIT",
"require": {
"php": "^7.2",
"anhskohbo/no-captcha": "^3.2",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/tinker": "^2.0",

62
flexiapi/composer.lock generated
View file

@ -4,8 +4,68 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "06757402a3ada8adde19707d8311f9f1",
"content-hash": "0e10a50683c7b16da67dfd0aa79d09c7",
"packages": [
{
"name": "anhskohbo/no-captcha",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/anhskohbo/no-captcha.git",
"reference": "c14dd67024f30fd28f38ac9faa44cc47e1d4bddf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/anhskohbo/no-captcha/zipball/c14dd67024f30fd28f38ac9faa44cc47e1d4bddf",
"reference": "c14dd67024f30fd28f38ac9faa44cc47e1d4bddf",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^6.2",
"illuminate/support": "^5.0|^6.0|^7.0",
"php": ">=5.5.5"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Anhskohbo\\NoCaptcha\\NoCaptchaServiceProvider"
],
"aliases": {
"NoCaptcha": "Anhskohbo\\NoCaptcha\\Facades\\NoCaptcha"
}
}
},
"autoload": {
"psr-4": {
"Anhskohbo\\NoCaptcha\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "anhskohbo",
"email": "anhskohbo@gmail.com"
}
],
"description": "No CAPTCHA reCAPTCHA For Laravel.",
"keywords": [
"captcha",
"laravel",
"laravel4",
"laravel5",
"laravel6",
"no-captcha",
"recaptcha"
],
"time": "2020-03-04T03:27:38+00:00"
},
{
"name": "dnoegel/php-xdg-base-dir",
"version": "v0.1.1",

View file

@ -135,6 +135,10 @@ return [
'attribute-name' => [
'rule-name' => 'custom-message',
],
'g-recaptcha-response' => [
'required' => 'Please verify that you are not a robot.',
'captcha' => 'Captcha error! try again later or contact site admin.',
],
],
/*

View file

@ -32,6 +32,11 @@
{!! Form::text('phone', old('phone'), ['class' => 'form-control', 'placeholder' => '+123456789']) !!}
</div>
<div class="form-group">
{!! NoCaptcha::renderJs() !!}
{!! NoCaptcha::display() !!}
</div>
{!! Form::submit('Register', ['class' => 'btn btn-primary float-right']) !!}
{!! Form::close() !!}

View file

@ -8,11 +8,13 @@
<a class="nav-link" href="{{ route('account.index') }}">{{ config('app.name') }}</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="{{ route('account.logout') }}">Logout</a>
</li>
</ul>
@if (Auth::check())
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="{{ route('account.logout') }}">Logout</a>
</li>
</ul>
@endif
</div>
</nav>
<div class="container-lg pt-3">