mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Add validation for GenerateExternalAccounts
Add a migration to change the accounts group column to 64 chars Update the dependencies Bump the package number
This commit is contained in:
parent
ae0ef3fb8e
commit
307c379fa8
4 changed files with 78 additions and 16 deletions
|
|
@ -4,8 +4,11 @@ namespace App\Console\Commands;
|
|||
|
||||
use App\Account;
|
||||
use App\Password;
|
||||
use App\Rules\NoUppercase;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class GenerateExternalAccounts extends Command
|
||||
|
|
@ -21,6 +24,40 @@ class GenerateExternalAccounts extends Command
|
|||
|
||||
public function handle()
|
||||
{
|
||||
$validator = Validator::make([
|
||||
'amount' => $this->argument('amount'),
|
||||
'group' => $this->argument('group'),
|
||||
], [
|
||||
'amount' => ['required', 'integer'],
|
||||
'group' => ['required', 'alpha-dash', new NoUppercase]
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$this->info('External accounts no created:');
|
||||
|
||||
foreach ($validator->errors()->all() as $error) {
|
||||
$this->error($error);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$groups = Account::distinct('group')
|
||||
->whereNotNull('group')
|
||||
->get('group')
|
||||
->pluck('group')
|
||||
->toArray();
|
||||
|
||||
if (!in_array($this->argument('group'), $groups)) {
|
||||
$this->info('Existing groups: '.implode(',', $groups));
|
||||
|
||||
if (!$this->confirm('You are creating a new group of External Account, are you sure?', false))
|
||||
{
|
||||
$this->info('Creation aborted');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$accounts = collect();
|
||||
$passwords = collect();
|
||||
$algorithm = 'SHA-256';
|
||||
|
|
@ -29,7 +66,7 @@ class GenerateExternalAccounts extends Command
|
|||
|
||||
while ($i < $this->argument('amount')) {
|
||||
$account = new Account;
|
||||
$account->username = $this->argument('group') . '_' . Str::random(6);
|
||||
$account->username = Str::random(12);
|
||||
$account->domain = config('app.sip_domain');
|
||||
$account->activated = 1;
|
||||
$account->ip_address = '127.0.0.1';
|
||||
|
|
|
|||
26
flexiapi/composer.lock
generated
26
flexiapi/composer.lock
generated
|
|
@ -1468,16 +1468,16 @@
|
|||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v8.83.19",
|
||||
"version": "v8.83.22",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "4264f2ee12330bdb1be050998f58ba7271236395"
|
||||
"reference": "96aecced5126d48e277e5339193c376fe82b6565"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/4264f2ee12330bdb1be050998f58ba7271236395",
|
||||
"reference": "4264f2ee12330bdb1be050998f58ba7271236395",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/96aecced5126d48e277e5339193c376fe82b6565",
|
||||
"reference": "96aecced5126d48e277e5339193c376fe82b6565",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1637,7 +1637,7 @@
|
|||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2022-07-13T13:23:09+00:00"
|
||||
"time": "2022-07-22T14:16:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
|
|
@ -2083,16 +2083,16 @@
|
|||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "2.7.0",
|
||||
"version": "2.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "5579edf28aee1190a798bfa5be8bc16c563bd524"
|
||||
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/5579edf28aee1190a798bfa5be8bc16c563bd524",
|
||||
"reference": "5579edf28aee1190a798bfa5be8bc16c563bd524",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50",
|
||||
"reference": "720488632c590286b88b80e62aa3d3d551ad4a50",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2112,11 +2112,10 @@
|
|||
"guzzlehttp/psr7": "^2.2",
|
||||
"mongodb/mongodb": "^1.8",
|
||||
"php-amqplib/php-amqplib": "~2.4 || ^3",
|
||||
"php-console/php-console": "^3.1.3",
|
||||
"phpspec/prophecy": "^1.15",
|
||||
"phpstan/phpstan": "^0.12.91",
|
||||
"phpunit/phpunit": "^8.5.14",
|
||||
"predis/predis": "^1.1",
|
||||
"predis/predis": "^1.1 || ^2.0",
|
||||
"rollbar/rollbar": "^1.3 || ^2 || ^3",
|
||||
"ruflin/elastica": "^7",
|
||||
"swiftmailer/swiftmailer": "^5.3|^6.0",
|
||||
|
|
@ -2136,7 +2135,6 @@
|
|||
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
||||
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
|
||||
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
||||
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
||||
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
||||
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
|
||||
},
|
||||
|
|
@ -2171,7 +2169,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Seldaek/monolog/issues",
|
||||
"source": "https://github.com/Seldaek/monolog/tree/2.7.0"
|
||||
"source": "https://github.com/Seldaek/monolog/tree/2.8.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -2183,7 +2181,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-06-09T08:59:12+00:00"
|
||||
"time": "2022-07-24T11:55:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ChangeGroupLengthFromAccountsTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->string('group', 64)->change();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->string('group', 16)->change();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#%define _datadir %{_datarootdir}
|
||||
#%define _docdir %{_datadir}/doc
|
||||
|
||||
%define build_number 145
|
||||
%define build_number 146
|
||||
%define var_dir /var/opt/belledonne-communications
|
||||
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue