This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\CustomerLogin;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Console\Command;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
class DeleteUnconfirmedCustomers extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'customer:deleteuc';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Delete the customers that haven\'t
|
|
confirmed their acocunt within 24 hours after the registeration.';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function handle()
|
|
{
|
|
$customersLogins = CustomerLogin::where([['status', 0], ['created_at', '<', Carbon::now()->subDay(1)]])->get();
|
|
foreach ($customersLogins as $customerLogin) {
|
|
// Si non activé et créer il y a plus d'un jour : Suppression.
|
|
$customerLogin->customer->infos()->where('brand_id', $customerLogin->brand_id)->first()->delete();
|
|
// On récupère son id pour le cas ou on doit le supprimer complètement après.
|
|
$customerId = $customerLogin->customer->id;
|
|
// Suppression de ses infos de login pour la marque.
|
|
$customerLogin->delete();
|
|
// Si le customer n'a plus d'info il n'a donc plus besoin de compte en crm.
|
|
if (count($customerLogin->customer->infos) === 0) {
|
|
// Suppression du customer une fois tout le reste supprimé.
|
|
$customer = Customer::find($customerId);
|
|
$customer->optInHistory()->delete();
|
|
$customer->delete();
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
}
|