mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-04-17 19:58:27 +00:00
Add a PHP CodeSniffer to the CI
This commit is contained in:
parent
a85088c7a4
commit
a0dd7e17ce
34 changed files with 279 additions and 108 deletions
|
|
@ -7,7 +7,7 @@ stages:
|
|||
- deploy
|
||||
|
||||
.rpm:
|
||||
tags: [ "docker" ]
|
||||
tags: ["docker"]
|
||||
|
||||
stage: package
|
||||
script:
|
||||
|
|
@ -26,13 +26,12 @@ centos7-rpm:
|
|||
extends: .rpm
|
||||
image: gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-centos7-php
|
||||
|
||||
|
||||
rocky8-rpm:
|
||||
extends: .rpm
|
||||
image: gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-rocky8-php
|
||||
|
||||
centos7-rpm-test:
|
||||
tags: [ "docker-centos7" ]
|
||||
tags: ["docker-centos7"]
|
||||
image: gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-centos7-php
|
||||
dependencies:
|
||||
- centos7-rpm
|
||||
|
|
@ -41,6 +40,7 @@ centos7-rpm-test:
|
|||
script:
|
||||
- yum -y localinstall rpmbuild/x86_64/*.rpm
|
||||
- cd /opt/belledonne-communications/share/flexisip-account-manager/flexiapi
|
||||
- scl enable rh-php73 "vendor/bin/phpcs"
|
||||
- scl enable rh-php73 "php artisan key:generate"
|
||||
- scl enable rh-php73 "vendor/bin/phpunit --log-junit $CI_PROJECT_DIR/flexiapi_phpunit.log"
|
||||
artifacts:
|
||||
|
|
@ -57,7 +57,6 @@ centos7-rpm-test:
|
|||
stage: deploy
|
||||
|
||||
.rpm-deploy:
|
||||
|
||||
script:
|
||||
- cd rpmbuild/x86_64
|
||||
- rsync -e "ssh -o StrictHostKeyChecking=no" -pr . $DEPLOY_SERVER:$DEPLOY_DIRECTORY_STATE;
|
||||
|
|
@ -71,32 +70,26 @@ centos7-rpm-test:
|
|||
extends:
|
||||
- .package-deploy
|
||||
|
||||
|
||||
.centos7-rpm-deploy:
|
||||
extends: .rpm-deploy
|
||||
tags: [ "docker-centos7" ]
|
||||
tags: ["docker-centos7"]
|
||||
|
||||
dependencies:
|
||||
- centos7-rpm
|
||||
|
||||
|
||||
|
||||
centos7-rpm-deploy-stable:
|
||||
|
||||
extends: .centos7-rpm-deploy
|
||||
variables:
|
||||
DEPLOY_DIRECTORY_STATE: $CENTOS7_DEPLOY_DIRECTORY_STABLE
|
||||
DEPLOY_DIRECTORY_STATE: $CENTOS7_DEPLOY_DIRECTORY_STABLE
|
||||
|
||||
centos7-rpm-deploy-alpha:
|
||||
|
||||
extends: .centos7-rpm-deploy
|
||||
variables:
|
||||
DEPLOY_DIRECTORY_STATE: $CENTOS7_DEPLOY_DIRECTORY_ALPHA
|
||||
|
||||
DEPLOY_DIRECTORY_STATE: $CENTOS7_DEPLOY_DIRECTORY_ALPHA
|
||||
|
||||
.rocky8-rpm-deploy:
|
||||
extends: .rpm-deploy
|
||||
tags: [ "docker" ]
|
||||
tags: ["docker"]
|
||||
dependencies:
|
||||
- rocky8-rpm
|
||||
|
||||
|
|
@ -108,10 +101,10 @@ centos7-rpm-deploy-alpha:
|
|||
rocky8-rpm-deploy-alpha:
|
||||
extends: .rocky8-rpm-deploy
|
||||
variables:
|
||||
DEPLOY_DIRECTORY_STATE: $CENTOS8_DEPLOY_DIRECTORY_ALPHA
|
||||
DEPLOY_DIRECTORY_STATE: $CENTOS8_DEPLOY_DIRECTORY_ALPHA
|
||||
|
||||
debian11-packaging:
|
||||
tags: [ "docker" ]
|
||||
tags: ["docker"]
|
||||
image: gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-debian11-php:20220413_flexiapi_packaging
|
||||
|
||||
stage: package
|
||||
|
|
@ -129,7 +122,7 @@ debian11-packaging:
|
|||
|
||||
.debian11-deploy:
|
||||
extends: .package-deploy
|
||||
tags: [ "docker" ]
|
||||
tags: ["docker"]
|
||||
image: gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-debian11-php:20220413_flexiapi_packaging
|
||||
dependencies:
|
||||
- debian11-packaging
|
||||
|
|
|
|||
1
Makefile
1
Makefile
|
|
@ -24,6 +24,7 @@ package-common:
|
|||
cp flexiapi/.env.example $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/.env.example
|
||||
cp flexiapi/artisan $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/
|
||||
cp flexiapi/phpunit.xml $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/
|
||||
cp flexiapi/phpcs.xml $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/
|
||||
|
||||
# General
|
||||
cp README.md $(OUTPUT_DIR)/flexisip-account-manager/
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ class ClearApiKeys extends Command
|
|||
|
||||
$this->info('Deleting api keys unused after ' . $minutes . ' minutes');
|
||||
|
||||
$count = ApiKey::where('last_used_at', '<',
|
||||
$count = ApiKey::where(
|
||||
'last_used_at',
|
||||
'<',
|
||||
Carbon::now()->subMinutes($minutes)->toDateTimeString()
|
||||
)->delete();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ class ClearNonces extends Command
|
|||
|
||||
public function handle()
|
||||
{
|
||||
$count = DigestNonce::where('created_at', '<',
|
||||
$count = DigestNonce::where(
|
||||
'created_at',
|
||||
'<',
|
||||
Carbon::now()->subMinutes($this->argument('minutes'))->toDateTimeString()
|
||||
)->delete();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ class ClearOldAccountsTombstones extends Command
|
|||
|
||||
public function handle()
|
||||
{
|
||||
$tombstones = AccountTombstone::where('created_at', '<',
|
||||
$tombstones = AccountTombstone::where(
|
||||
'created_at',
|
||||
'<',
|
||||
Carbon::now()->subDays($this->argument('days'))->toDateTimeString()
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ class GenerateExternalAccounts extends Command
|
|||
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))
|
||||
{
|
||||
if (!$this->confirm('You are creating a new group of External Account, are you sure?', false)) {
|
||||
$this->info('Creation aborted');
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class ImportDatabase extends Command
|
|||
{
|
||||
protected $signature = 'db:import {dbname} {sqlite-file-path?} {--u|username=} {--p|password=} {--P|port=3306} {--t|type=mysql} {--host=localhost} {--accounts-table=accounts} {--aliases-table=aliases} {--passwords-table=passwords}';
|
||||
protected $description = 'Import an existing Flexisip database into FlexiAPI';
|
||||
private $_pagination = 1000;
|
||||
private $pagination = 1000;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -92,13 +92,13 @@ class ImportDatabase extends Command
|
|||
// Accounts
|
||||
$this->info('Migrating the accounts');
|
||||
|
||||
$pages = $accountsCount / $this->_pagination;
|
||||
$pages = $accountsCount / $this->pagination;
|
||||
$bar = $this->output->createProgressBar($pages);
|
||||
|
||||
for ($page = 0; $page <= $pages; $page++) {
|
||||
$originAccounts = Capsule::table($this->option('accounts-table'))
|
||||
->take($this->_pagination)
|
||||
->skip($page*$this->_pagination)
|
||||
->take($this->pagination)
|
||||
->skip($page*$this->pagination)
|
||||
->get()
|
||||
->map(function ($element) {
|
||||
// Fix bad creation_time
|
||||
|
|
@ -124,13 +124,13 @@ class ImportDatabase extends Command
|
|||
// Passwords
|
||||
$this->info('Migrating the passwords');
|
||||
|
||||
$pages = Capsule::table($this->option('passwords-table'))->count() / $this->_pagination;
|
||||
$pages = Capsule::table($this->option('passwords-table'))->count() / $this->pagination;
|
||||
$bar = $this->output->createProgressBar($pages);
|
||||
|
||||
for ($page = 0; $page <= $pages; $page++) {
|
||||
$originPasswords = Capsule::table($this->option('passwords-table'))
|
||||
->take($this->_pagination)
|
||||
->skip($page*$this->_pagination)
|
||||
->take($this->pagination)
|
||||
->skip($page*$this->pagination)
|
||||
->get()
|
||||
->map(function ($element) {
|
||||
return (array)$element;
|
||||
|
|
@ -149,13 +149,13 @@ class ImportDatabase extends Command
|
|||
// Aliases
|
||||
$this->info('Migrating the aliases');
|
||||
|
||||
$pages = Capsule::table($this->option('aliases-table'))->count() / $this->_pagination;
|
||||
$pages = Capsule::table($this->option('aliases-table'))->count() / $this->pagination;
|
||||
$bar = $this->output->createProgressBar($pages);
|
||||
|
||||
for ($page = 0; $page <= $pages; $page++) {
|
||||
$originAliases = Capsule::table($this->option('aliases-table'))
|
||||
->take($this->_pagination)
|
||||
->skip($page*$this->_pagination)
|
||||
->take($this->pagination)
|
||||
->skip($page*$this->pagination)
|
||||
->get()
|
||||
->map(function ($element) {
|
||||
return (array)$element;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ class RemoveUnconfirmedAccounts extends Command
|
|||
|
||||
public function handle()
|
||||
{
|
||||
$accounts = Account::where('creation_time', '<',
|
||||
$accounts = Account::where(
|
||||
'creation_time',
|
||||
'<',
|
||||
Carbon::now()->subDays($this->argument('days'))->toDateTimeString()
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,21 +29,25 @@ class DeviceController extends Controller
|
|||
{
|
||||
$connector = new FlexisipConnector;
|
||||
|
||||
return view('account.devices.index',
|
||||
return view(
|
||||
'account.devices.index',
|
||||
['devices' => $connector->getDevices($request->user()->identifier)
|
||||
->keyBy('uuid')
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(Request $request, string $uuid)
|
||||
{
|
||||
$connector = new FlexisipConnector;
|
||||
|
||||
return view('account.devices.delete',
|
||||
return view(
|
||||
'account.devices.delete',
|
||||
['device' => $connector->getDevices($request->user()->identifier)
|
||||
->keyBy('uuid')
|
||||
->where('uuid', $uuid)
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function destroy(Request $request, string $uuid)
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class ProvisioningController extends Controller
|
|||
// Account handling
|
||||
if ($requestAccount) {
|
||||
$account = $requestAccount;
|
||||
} else if ($provisioningToken) {
|
||||
} elseif ($provisioningToken) {
|
||||
$account = Account::withoutGlobalScopes()
|
||||
->where('provisioning_token', $provisioningToken)
|
||||
->first();
|
||||
|
|
@ -211,8 +211,7 @@ class ProvisioningController extends Controller
|
|||
|
||||
if ($provisioningToken) {
|
||||
// Activate the account
|
||||
if (
|
||||
$account->activated == false
|
||||
if ($account->activated == false
|
||||
&& $provisioningToken == $account->provisioning_token
|
||||
) {
|
||||
$account->activated = true;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class AccountAccountTypeController extends Controller
|
|||
|
||||
return view('admin.account.account_type.create', [
|
||||
'account' => $account,
|
||||
'account_types' => AccountType::whereNotIn('id', function($query) use ($account) {
|
||||
'account_types' => AccountType::whereNotIn('id', function ($query) use ($account) {
|
||||
$query->select('account_type_id')
|
||||
->from('account_account_type')
|
||||
->where('account_id', $account->id);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class AccountController extends Controller
|
|||
|
||||
$request->merge(['phone' => $phone]);
|
||||
$request->validate([
|
||||
'phone' => [ 'required', new WithoutSpaces, 'starts_with:+']
|
||||
'phone' => ['required', new WithoutSpaces, 'starts_with:+']
|
||||
]);
|
||||
|
||||
$alias = Alias::where('alias', $phone)->first();
|
||||
|
|
@ -144,10 +144,8 @@ class AccountController extends Controller
|
|||
|
||||
$ovhSMS = new OvhSMS;
|
||||
$ovhSMS->send($request->get('phone'), 'Your ' . config('app.name') . ' recovery code is ' . $account->confirmation_key);
|
||||
}
|
||||
|
||||
// Send validation by email
|
||||
elseif ($request->has('email')) {
|
||||
} elseif ($request->has('email')) {
|
||||
// Send validation by email
|
||||
$account->confirmation_key = Str::random(WebAuthenticateController::$emailCodeSize);
|
||||
$account->save();
|
||||
|
||||
|
|
@ -199,8 +197,8 @@ class AccountController extends Controller
|
|||
if (!config('app.dangerous_endpoints')) return abort(404);
|
||||
|
||||
$account = Account::sip($sip)
|
||||
->where('confirmation_key', $recoveryKey)
|
||||
->firstOrFail();
|
||||
->where('confirmation_key', $recoveryKey)
|
||||
->firstOrFail();
|
||||
|
||||
if ($account->activationExpired()) abort(403, 'Activation expired');
|
||||
|
||||
|
|
@ -238,7 +236,7 @@ class AccountController extends Controller
|
|||
Rule::exists('account_creation_tokens', 'token')->where(function ($query) {
|
||||
$query->where('used', false);
|
||||
}),
|
||||
'size:'.WebAuthenticateController::$emailCodeSize
|
||||
'size:' . WebAuthenticateController::$emailCodeSize
|
||||
],
|
||||
// For retro-compatibility
|
||||
'token' => [
|
||||
|
|
@ -246,7 +244,7 @@ class AccountController extends Controller
|
|||
Rule::exists('account_creation_tokens', 'token')->where(function ($query) {
|
||||
$query->where('used', false);
|
||||
}),
|
||||
'size:'.WebAuthenticateController::$emailCodeSize
|
||||
'size:' . WebAuthenticateController::$emailCodeSize
|
||||
],
|
||||
]);
|
||||
|
||||
|
|
@ -277,12 +275,12 @@ class AccountController extends Controller
|
|||
public function activateEmail(Request $request, string $sip)
|
||||
{
|
||||
$request->validate([
|
||||
'code' => 'required|size:'.WebAuthenticateController::$emailCodeSize
|
||||
'code' => 'required|size:' . WebAuthenticateController::$emailCodeSize
|
||||
]);
|
||||
|
||||
$account = Account::sip($sip)
|
||||
->where('confirmation_key', $request->get('code'))
|
||||
->firstOrFail();
|
||||
->where('confirmation_key', $request->get('code'))
|
||||
->firstOrFail();
|
||||
|
||||
if ($account->activationExpired()) abort(403, 'Activation expired');
|
||||
|
||||
|
|
@ -302,8 +300,8 @@ class AccountController extends Controller
|
|||
]);
|
||||
|
||||
$account = Account::sip($sip)
|
||||
->where('confirmation_key', $request->get('code'))
|
||||
->firstOrFail();
|
||||
->where('confirmation_key', $request->get('code'))
|
||||
->firstOrFail();
|
||||
|
||||
if ($account->activationExpired()) abort(403, 'Activation expired');
|
||||
|
||||
|
|
@ -319,8 +317,8 @@ class AccountController extends Controller
|
|||
public function show(Request $request)
|
||||
{
|
||||
return Account::where('id', $request->user()->id)
|
||||
->without(['api_key', 'email_changed.new_email'])
|
||||
->first();
|
||||
->without(['api_key', 'email_changed.new_email'])
|
||||
->first();
|
||||
}
|
||||
|
||||
public function provision(Request $request)
|
||||
|
|
@ -344,6 +342,6 @@ class AccountController extends Controller
|
|||
}
|
||||
|
||||
return Account::where('id', $request->user()->id)
|
||||
->delete();
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class MessageController extends Controller
|
|||
->then(function (\React\Socket\Connection $connection) use ($request, &$returnedLines) {
|
||||
$connection->on('data', function ($message) use ($connection, &$returnedLines) {
|
||||
foreach (preg_split("/\r\n|\n|\r/", $message) as $line) {
|
||||
if(!empty($line) && false !== ($matches = explode(':', $line, 2))) {
|
||||
if (!empty($line) && false !== ($matches = explode(':', $line, 2))) {
|
||||
$returnedLines["{$matches[0]}"] = trim($matches[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
hop
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,17 +23,17 @@ use App\Device;
|
|||
|
||||
class FlexisipConnector
|
||||
{
|
||||
private $_socket;
|
||||
private $socket;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$pid = file_get_contents(config('app.flexisip_proxy_pid'));
|
||||
$this->_socket = stream_socket_client('unix:///tmp/flexisip-proxy-'.$pid, $errno, $errstr);
|
||||
$this->socket = streamsocket_client('unix:///tmp/flexisip-proxy-'.$pid, $errno, $errstr);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
fclose($this->_socket);
|
||||
fclose($this->socket);
|
||||
}
|
||||
|
||||
public function getDevices(string $from)
|
||||
|
|
@ -64,7 +64,7 @@ class FlexisipConnector
|
|||
|
||||
private function request(string $command, array $parameters)
|
||||
{
|
||||
fwrite($this->_socket, $command.' '.\implode(' ', $parameters));
|
||||
return json_decode(fread($this->_socket, 8192));
|
||||
fwrite($this->socket, $command.' '.\implode(' ', $parameters));
|
||||
return json_decode(fread($this->socket, 8192));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,4 @@ class FlexisipPusherConnector
|
|||
|
||||
return exec($command, $output, $retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ use Illuminate\Support\Facades\Log;
|
|||
|
||||
class OvhSMS
|
||||
{
|
||||
private $_api;
|
||||
private $_smsService;
|
||||
private $api;
|
||||
private $smsService;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ class OvhSMS
|
|||
Log::error('OVH SMS API not configured');
|
||||
}
|
||||
|
||||
$this->_api = new Api(
|
||||
$this->api = new Api(
|
||||
config('ovh.app_key'),
|
||||
config('ovh.app_secret'),
|
||||
config('ovh.app_endpoint'),
|
||||
|
|
@ -41,10 +41,10 @@ class OvhSMS
|
|||
);
|
||||
|
||||
try {
|
||||
$smsServices = $this->_api->get('/sms/');
|
||||
$smsServices = $this->api->get('/sms/');
|
||||
|
||||
if (!empty($smsServices)) {
|
||||
$this->_smsService = $smsServices[0];
|
||||
$this->smsService = $smsServices[0];
|
||||
}
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
Log::error('OVH SMS API not reachable: ' . $e->getMessage());
|
||||
|
|
@ -53,7 +53,7 @@ class OvhSMS
|
|||
|
||||
public function send(string $to, string $message)
|
||||
{
|
||||
if (!$this->_smsService) {
|
||||
if (!$this->smsService) {
|
||||
Log::error('OVH SMS API not configured');
|
||||
return;
|
||||
}
|
||||
|
|
@ -72,12 +72,12 @@ class OvhSMS
|
|||
];
|
||||
|
||||
try {
|
||||
$this->_api->post('/sms/'. $this->_smsService . '/jobs', $content);
|
||||
$this->api->post('/sms/'. $this->smsService . '/jobs', $content);
|
||||
// One credit removed
|
||||
|
||||
$this->_api->get('/sms/'. $this->_smsService . '/jobs');
|
||||
$this->api->get('/sms/'. $this->smsService . '/jobs');
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
Log::error('OVH SMS not sent: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ use Carbon\CarbonInterval;
|
|||
|
||||
use App\Account;
|
||||
|
||||
|
||||
class StatisticsCruncher
|
||||
{
|
||||
public static function month()
|
||||
|
|
@ -39,7 +38,7 @@ class StatisticsCruncher
|
|||
))->each->setAppends([])->pluck('count', 'moment');
|
||||
|
||||
$dataAliases = self::getAccountFrom(Carbon::now()->subMonth())
|
||||
->whereIn('id', function($query) {
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select('account_id')
|
||||
->from('aliases');
|
||||
})
|
||||
|
|
@ -57,7 +56,7 @@ class StatisticsCruncher
|
|||
|
||||
$dataAliasesActivated = self::getAccountFrom(Carbon::now()->subMonth())
|
||||
->where('activated', true)
|
||||
->whereIn('id', function($query) {
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select('account_id')
|
||||
->from('aliases');
|
||||
})
|
||||
|
|
@ -84,7 +83,7 @@ class StatisticsCruncher
|
|||
))->each->setAppends([])->pluck('count', 'moment');
|
||||
|
||||
$dataAliases = self::getAccountFrom(Carbon::now()->subWeek())
|
||||
->whereIn('id', function($query) {
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select('account_id')
|
||||
->from('aliases');
|
||||
})
|
||||
|
|
@ -102,7 +101,7 @@ class StatisticsCruncher
|
|||
|
||||
$dataAliasesActivated = self::getAccountFrom(Carbon::now()->subWeek())
|
||||
->where('activated', true)
|
||||
->whereIn('id', function($query) {
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select('account_id')
|
||||
->from('aliases');
|
||||
})
|
||||
|
|
@ -129,7 +128,7 @@ class StatisticsCruncher
|
|||
))->each->setAppends([])->pluck('count', 'moment');
|
||||
|
||||
$dataAliases = self::getAccountFrom(Carbon::now()->subDay())
|
||||
->whereIn('id', function($query) {
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select('account_id')
|
||||
->from('aliases');
|
||||
})
|
||||
|
|
@ -147,7 +146,7 @@ class StatisticsCruncher
|
|||
|
||||
$dataAliasesActivated = self::getAccountFrom(Carbon::now()->subDay())
|
||||
->where('activated', true)
|
||||
->whereIn('id', function($query) {
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select('account_id')
|
||||
->from('aliases');
|
||||
})
|
||||
|
|
@ -194,4 +193,4 @@ class StatisticsCruncher
|
|||
|
||||
return $stats;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ class ChangingEmail extends Mailable
|
|||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private $_account;
|
||||
private $account;
|
||||
|
||||
public function __construct(Account $account)
|
||||
{
|
||||
$this->_account = $account;
|
||||
$this->account = $account;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->view('mails.changing_email')
|
||||
->text('mails.changing_email_text')
|
||||
->with(['account' => $this->_account]);
|
||||
->with(['account' => $this->account]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ class ConfirmedRegistration extends Mailable
|
|||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private $_account;
|
||||
private $account;
|
||||
|
||||
public function __construct(Account $account)
|
||||
{
|
||||
$this->_account = $account;
|
||||
$this->account = $account;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->view('mails.confirmed_registration')
|
||||
->text('mails.confirmed_registration_text')
|
||||
->with(['account' => $this->_account]);
|
||||
->with(['account' => $this->account]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ class NewsletterRegistration extends Mailable
|
|||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private $_account;
|
||||
private $account;
|
||||
|
||||
public function __construct(Account $account)
|
||||
{
|
||||
$this->_account = $account;
|
||||
$this->account = $account;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->view('mails.newsletter_registration')
|
||||
->text('mails.newsletter_registration_text')
|
||||
->with(['account' => $this->_account]);
|
||||
->with(['account' => $this->account]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ class PasswordAuthentication extends Mailable
|
|||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private $_account;
|
||||
private $account;
|
||||
|
||||
public function __construct(Account $account)
|
||||
{
|
||||
$this->_account = $account;
|
||||
$this->account = $account;
|
||||
}
|
||||
|
||||
public function build()
|
||||
|
|
@ -41,7 +41,7 @@ class PasswordAuthentication extends Mailable
|
|||
return $this->view('mails.authentication')
|
||||
->text('mails.authentication_text')
|
||||
->with([
|
||||
'link' => route('account.authenticate.email_confirm', [$this->_account->confirmation_key])
|
||||
'link' => route('account.authenticate.email_confirm', [$this->account->confirmation_key])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ class RegisterConfirmation extends Mailable
|
|||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private $_account;
|
||||
private $account;
|
||||
|
||||
public function __construct(Account $account)
|
||||
{
|
||||
$this->_account = $account;
|
||||
$this->account = $account;
|
||||
}
|
||||
|
||||
public function build()
|
||||
|
|
@ -41,7 +41,7 @@ class RegisterConfirmation extends Mailable
|
|||
return $this->view('mails.register_confirmation')
|
||||
->text('mails.register_confirmation_text')
|
||||
->with([
|
||||
'link' => route('account.authenticate.email_confirm', [$this->_account->confirmation_key])
|
||||
'link' => route('account.authenticate.email_confirm', [$this->account->confirmation_key])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@
|
|||
"fzaninotto/faker": "^1.9",
|
||||
"mockery/mockery": "^1.4",
|
||||
"nunomaduro/collision": "^5.0",
|
||||
"phpunit/phpunit": "^9.0"
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
|
|
|
|||
58
flexiapi/composer.lock
generated
58
flexiapi/composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "ccb0b3bfece8b9d8545c41c3a816aa51",
|
||||
"content-hash": "5491f03249bb73afd568b82584b43311",
|
||||
"packages": [
|
||||
{
|
||||
"name": "anhskohbo/no-captcha",
|
||||
|
|
@ -8709,6 +8709,62 @@
|
|||
],
|
||||
"time": "2020-09-28T06:39:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
||||
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619",
|
||||
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-simplexml": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/phpcs",
|
||||
"bin/phpcbf"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Sherwood",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
||||
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"keywords": [
|
||||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
|
||||
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
|
||||
},
|
||||
"time": "2022-06-18T07:21:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
"version": "1.2.1",
|
||||
|
|
|
|||
111
flexiapi/phpcs.xml
Normal file
111
flexiapi/phpcs.xml
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="Laravel Standards">
|
||||
|
||||
<description>The Laravel Coding Standards</description>
|
||||
|
||||
<rule ref="Generic.Classes.DuplicateClassName"/>
|
||||
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
|
||||
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
|
||||
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
|
||||
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
|
||||
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
|
||||
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
|
||||
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
||||
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
|
||||
<rule ref="Generic.Commenting.Todo"/>
|
||||
<rule ref="Generic.Commenting.Fixme"/>
|
||||
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
|
||||
<rule ref="Generic.Files.ByteOrderMark"/>
|
||||
<rule ref="Generic.Files.LineEndings"/>
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="120"/>
|
||||
<property name="absoluteLineLimit" value="150"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
||||
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
|
||||
<rule ref="Generic.Formatting.SpaceAfterCast"/>
|
||||
<rule ref="Generic.Functions.CallTimePassByReference"/>
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
|
||||
<rule ref="Generic.Metrics.CyclomaticComplexity">
|
||||
<properties>
|
||||
<property name="complexity" value="50"/>
|
||||
<property name="absoluteComplexity" value="100"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.Metrics.NestingLevel">
|
||||
<properties>
|
||||
<property name="nestingLevel" value="10"/>
|
||||
<property name="absoluteNestingLevel" value="30"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.NamingConventions.ConstructorName"/>
|
||||
<rule ref="Generic.PHP.LowerCaseConstant"/>
|
||||
<rule ref="Generic.PHP.DeprecatedFunctions"/>
|
||||
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
||||
<rule ref="Generic.PHP.ForbiddenFunctions"/>
|
||||
<rule ref="Generic.PHP.NoSilencedErrors"/>
|
||||
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||
<properties>
|
||||
<property name="indent" value="4"/>
|
||||
<property name="tabIndent" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="MySource.PHP.EvalObjectFactory"/>
|
||||
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
||||
<rule ref="PSR1.Files.SideEffects"/>
|
||||
<rule ref="PSR2.Classes.ClassDeclaration"/>
|
||||
<rule ref="PSR2.Classes.PropertyDeclaration"/>
|
||||
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
|
||||
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
|
||||
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
|
||||
<rule ref="PSR2.Files.EndFileNewline"/>
|
||||
<rule ref="PSR2.Methods.MethodDeclaration"/>
|
||||
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
|
||||
<rule ref="PSR2.Namespaces.UseDeclaration"/>
|
||||
<rule ref="Zend.Files.ClosingTag"/>
|
||||
<rule ref="PSR1">
|
||||
<exclude-pattern>*.php</exclude-pattern>
|
||||
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
|
||||
</rule>
|
||||
<rule ref="Generic">
|
||||
<exclude-pattern>*.php</exclude-pattern>
|
||||
<exclude name="Generic.Strings.UnnecessaryStringConcat.Found"/>
|
||||
</rule>
|
||||
|
||||
<file>app</file>
|
||||
<file>config</file>
|
||||
<file>public</file>
|
||||
<file>resources</file>
|
||||
<file>routes</file>
|
||||
<file>tests</file>
|
||||
|
||||
<exclude-pattern>*/database/*</exclude-pattern>
|
||||
<exclude-pattern>*/cache/*</exclude-pattern>
|
||||
<exclude-pattern>*/*.js</exclude-pattern>
|
||||
<exclude-pattern>*/*.css</exclude-pattern>
|
||||
<exclude-pattern>*/*.xml</exclude-pattern>
|
||||
<exclude-pattern>*/*.blade.php</exclude-pattern>
|
||||
<exclude-pattern>*/autoload.php</exclude-pattern>
|
||||
<exclude-pattern>*/storage/*</exclude-pattern>
|
||||
<exclude-pattern>*/docs/*</exclude-pattern>
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/migrations/*</exclude-pattern>
|
||||
<exclude-pattern>*/config/*</exclude-pattern>
|
||||
<exclude-pattern>*/public/index.php</exclude-pattern>
|
||||
<exclude-pattern>*/Middleware/*</exclude-pattern>
|
||||
<exclude-pattern>*/Console/Kernel.php</exclude-pattern>
|
||||
<exclude-pattern>*/Exceptions/Handler.php</exclude-pattern>
|
||||
<exclude-pattern>*/Http/Kernel.php</exclude-pattern>
|
||||
<exclude-pattern>*/Providers/*</exclude-pattern>
|
||||
|
||||
<arg name="colors"/>
|
||||
<ini name="memory_limit" value="128M"/>
|
||||
|
||||
<rule ref="PSR2"/>
|
||||
|
||||
</ruleset>
|
||||
|
|
@ -113,4 +113,4 @@ Route::group(['middleware' => ['auth.digest_or_key']], function () {
|
|||
Route::post('accounts/{id}/types/{type_id}', 'Api\Admin\AccountController@typeAdd');
|
||||
Route::delete('accounts/{id}/types/{type_id}', 'Api\Admin\AccountController@typeRemove');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -145,4 +145,4 @@ if (config('app.web_panel')) {
|
|||
Route::get('admin/accounts/{account}/actions/{action_id}/delete', 'Admin\AccountActionController@delete')->name('admin.account.action.delete');
|
||||
Route::delete('admin/accounts/{account}/actions/{action_id}', 'Admin\AccountActionController@destroy')->name('admin.account.action.destroy');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,4 +121,4 @@ class AccountApiKeyTest extends TestCase
|
|||
// Check if the account was correctly attached
|
||||
$this->assertEquals(json_decode($response)->email, $password->account->email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,4 +136,4 @@ class AccountCreationTokenTest extends TestCase
|
|||
]);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,4 +55,4 @@ class AccountMessageTest extends TestCase
|
|||
$json->has('id');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,4 +90,4 @@ class AccountPhoneChangeTest extends TestCase
|
|||
'phone' => $phone
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,4 +179,4 @@ class AccountProvisioningTest extends TestCase
|
|||
$this->get($this->route.'/auth_token/'.$authToken)
|
||||
->assertStatus(404);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ abstract class TestCase extends BaseTestCase
|
|||
|
||||
$A1 = $password->password;
|
||||
$A2 = hash($hash, $this->method . ':' . $this->route);
|
||||
$response = hash($hash,
|
||||
$response = hash(
|
||||
$hash,
|
||||
sprintf(
|
||||
'%s:%s:%s:%s:%s:%s',
|
||||
$A1,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue