diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdfbaed..6c73853 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/Makefile b/Makefile index 9561768..571bd9a 100644 --- a/Makefile +++ b/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/ diff --git a/flexiapi/app/Console/Commands/ClearApiKeys.php b/flexiapi/app/Console/Commands/ClearApiKeys.php index 91b11f7..e23dd27 100644 --- a/flexiapi/app/Console/Commands/ClearApiKeys.php +++ b/flexiapi/app/Console/Commands/ClearApiKeys.php @@ -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(); diff --git a/flexiapi/app/Console/Commands/ClearNonces.php b/flexiapi/app/Console/Commands/ClearNonces.php index 4dd9b50..5788f7e 100644 --- a/flexiapi/app/Console/Commands/ClearNonces.php +++ b/flexiapi/app/Console/Commands/ClearNonces.php @@ -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(); diff --git a/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php b/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php index 75bc2ae..7a695e8 100644 --- a/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php +++ b/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php @@ -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() ); diff --git a/flexiapi/app/Console/Commands/GenerateExternalAccounts.php b/flexiapi/app/Console/Commands/GenerateExternalAccounts.php index 145ed38..062c6b7 100644 --- a/flexiapi/app/Console/Commands/GenerateExternalAccounts.php +++ b/flexiapi/app/Console/Commands/GenerateExternalAccounts.php @@ -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; } diff --git a/flexiapi/app/Console/Commands/ImportDatabase.php b/flexiapi/app/Console/Commands/ImportDatabase.php index 8cfd933..4b8f325 100644 --- a/flexiapi/app/Console/Commands/ImportDatabase.php +++ b/flexiapi/app/Console/Commands/ImportDatabase.php @@ -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; diff --git a/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php b/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php index b1049ed..3f44cdc 100644 --- a/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php +++ b/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php @@ -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() ); diff --git a/flexiapi/app/Http/Controllers/Account/DeviceController.php b/flexiapi/app/Http/Controllers/Account/DeviceController.php index 2b79dca..fd78f1e 100644 --- a/flexiapi/app/Http/Controllers/Account/DeviceController.php +++ b/flexiapi/app/Http/Controllers/Account/DeviceController.php @@ -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) diff --git a/flexiapi/app/Http/Controllers/Account/ProvisioningController.php b/flexiapi/app/Http/Controllers/Account/ProvisioningController.php index d288491..ceeedf3 100644 --- a/flexiapi/app/Http/Controllers/Account/ProvisioningController.php +++ b/flexiapi/app/Http/Controllers/Account/ProvisioningController.php @@ -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; diff --git a/flexiapi/app/Http/Controllers/Admin/AccountAccountTypeController.php b/flexiapi/app/Http/Controllers/Admin/AccountAccountTypeController.php index f1868da..d64d955 100644 --- a/flexiapi/app/Http/Controllers/Admin/AccountAccountTypeController.php +++ b/flexiapi/app/Http/Controllers/Admin/AccountAccountTypeController.php @@ -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); diff --git a/flexiapi/app/Http/Controllers/Api/AccountController.php b/flexiapi/app/Http/Controllers/Api/AccountController.php index c06feca..a352c85 100644 --- a/flexiapi/app/Http/Controllers/Api/AccountController.php +++ b/flexiapi/app/Http/Controllers/Api/AccountController.php @@ -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(); } } diff --git a/flexiapi/app/Http/Controllers/Api/MessageController.php b/flexiapi/app/Http/Controllers/Api/MessageController.php index 5d3882d..2f66724 100644 --- a/flexiapi/app/Http/Controllers/Api/MessageController.php +++ b/flexiapi/app/Http/Controllers/Api/MessageController.php @@ -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]); } } diff --git a/flexiapi/app/Http/Middleware/Authenticate.php b/flexiapi/app/Http/Middleware/Authenticate.php index 18ed0ec..1fd242e 100644 --- a/flexiapi/app/Http/Middleware/Authenticate.php +++ b/flexiapi/app/Http/Middleware/Authenticate.php @@ -1,6 +1,7 @@ _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)); } -} \ No newline at end of file +} diff --git a/flexiapi/app/Libraries/FlexisipPusherConnector.php b/flexiapi/app/Libraries/FlexisipPusherConnector.php index f642691..6f5be04 100644 --- a/flexiapi/app/Libraries/FlexisipPusherConnector.php +++ b/flexiapi/app/Libraries/FlexisipPusherConnector.php @@ -50,4 +50,4 @@ class FlexisipPusherConnector return exec($command, $output, $retval); } -} \ No newline at end of file +} diff --git a/flexiapi/app/Libraries/OvhSMS.php b/flexiapi/app/Libraries/OvhSMS.php index 1311dc8..1dfc536 100644 --- a/flexiapi/app/Libraries/OvhSMS.php +++ b/flexiapi/app/Libraries/OvhSMS.php @@ -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()); } } -} \ No newline at end of file +} diff --git a/flexiapi/app/Libraries/StatisticsCruncher.php b/flexiapi/app/Libraries/StatisticsCruncher.php index 4fb2c31..9833f8b 100644 --- a/flexiapi/app/Libraries/StatisticsCruncher.php +++ b/flexiapi/app/Libraries/StatisticsCruncher.php @@ -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; } -} \ No newline at end of file +} diff --git a/flexiapi/app/Mail/ChangingEmail.php b/flexiapi/app/Mail/ChangingEmail.php index 50d1f70..1e6ea65 100644 --- a/flexiapi/app/Mail/ChangingEmail.php +++ b/flexiapi/app/Mail/ChangingEmail.php @@ -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]); } } diff --git a/flexiapi/app/Mail/ConfirmedRegistration.php b/flexiapi/app/Mail/ConfirmedRegistration.php index d62ef82..a883419 100644 --- a/flexiapi/app/Mail/ConfirmedRegistration.php +++ b/flexiapi/app/Mail/ConfirmedRegistration.php @@ -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]); } } diff --git a/flexiapi/app/Mail/NewsletterRegistration.php b/flexiapi/app/Mail/NewsletterRegistration.php index 813c964..5176984 100644 --- a/flexiapi/app/Mail/NewsletterRegistration.php +++ b/flexiapi/app/Mail/NewsletterRegistration.php @@ -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]); } } diff --git a/flexiapi/app/Mail/PasswordAuthentication.php b/flexiapi/app/Mail/PasswordAuthentication.php index 17c9005..10881e5 100644 --- a/flexiapi/app/Mail/PasswordAuthentication.php +++ b/flexiapi/app/Mail/PasswordAuthentication.php @@ -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]) ]); } } diff --git a/flexiapi/app/Mail/RegisterConfirmation.php b/flexiapi/app/Mail/RegisterConfirmation.php index 6ee5ffa..d89cc21 100644 --- a/flexiapi/app/Mail/RegisterConfirmation.php +++ b/flexiapi/app/Mail/RegisterConfirmation.php @@ -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]) ]); } } diff --git a/flexiapi/composer.json b/flexiapi/composer.json index e542068..66cef93 100644 --- a/flexiapi/composer.json +++ b/flexiapi/composer.json @@ -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": { diff --git a/flexiapi/composer.lock b/flexiapi/composer.lock index bdbc419..044d30f 100644 --- a/flexiapi/composer.lock +++ b/flexiapi/composer.lock @@ -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", diff --git a/flexiapi/phpcs.xml b/flexiapi/phpcs.xml new file mode 100644 index 0000000..3547cde --- /dev/null +++ b/flexiapi/phpcs.xml @@ -0,0 +1,111 @@ + + + + The Laravel Coding Standards + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *.php + + + + *.php + + + + app + config + public + resources + routes + tests + + */database/* + */cache/* + */*.js + */*.css + */*.xml + */*.blade.php + */autoload.php + */storage/* + */docs/* + */vendor/* + */migrations/* + */config/* + */public/index.php + */Middleware/* + */Console/Kernel.php + */Exceptions/Handler.php + */Http/Kernel.php + */Providers/* + + + + + + + diff --git a/flexiapi/routes/api.php b/flexiapi/routes/api.php index 02c9b77..03e304d 100644 --- a/flexiapi/routes/api.php +++ b/flexiapi/routes/api.php @@ -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'); }); -}); \ No newline at end of file +}); diff --git a/flexiapi/routes/web.php b/flexiapi/routes/web.php index afa0a73..679bd36 100644 --- a/flexiapi/routes/web.php +++ b/flexiapi/routes/web.php @@ -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'); }); -} \ No newline at end of file +} diff --git a/flexiapi/tests/Feature/AccountApiKeyTest.php b/flexiapi/tests/Feature/AccountApiKeyTest.php index a7bc6a5..957b6a9 100644 --- a/flexiapi/tests/Feature/AccountApiKeyTest.php +++ b/flexiapi/tests/Feature/AccountApiKeyTest.php @@ -121,4 +121,4 @@ class AccountApiKeyTest extends TestCase // Check if the account was correctly attached $this->assertEquals(json_decode($response)->email, $password->account->email); } -} \ No newline at end of file +} diff --git a/flexiapi/tests/Feature/AccountCreationTokenTest.php b/flexiapi/tests/Feature/AccountCreationTokenTest.php index 729028a..b73099b 100644 --- a/flexiapi/tests/Feature/AccountCreationTokenTest.php +++ b/flexiapi/tests/Feature/AccountCreationTokenTest.php @@ -136,4 +136,4 @@ class AccountCreationTokenTest extends TestCase ]); $response->assertStatus(422); } -} \ No newline at end of file +} diff --git a/flexiapi/tests/Feature/AccountMessageTest.php b/flexiapi/tests/Feature/AccountMessageTest.php index 1b3db7a..2cdd5c0 100644 --- a/flexiapi/tests/Feature/AccountMessageTest.php +++ b/flexiapi/tests/Feature/AccountMessageTest.php @@ -55,4 +55,4 @@ class AccountMessageTest extends TestCase $json->has('id'); }); } -} \ No newline at end of file +} diff --git a/flexiapi/tests/Feature/AccountPhoneChangeTest.php b/flexiapi/tests/Feature/AccountPhoneChangeTest.php index 039225e..29788db 100644 --- a/flexiapi/tests/Feature/AccountPhoneChangeTest.php +++ b/flexiapi/tests/Feature/AccountPhoneChangeTest.php @@ -90,4 +90,4 @@ class AccountPhoneChangeTest extends TestCase 'phone' => $phone ]); } -} \ No newline at end of file +} diff --git a/flexiapi/tests/Feature/AccountProvisioningTest.php b/flexiapi/tests/Feature/AccountProvisioningTest.php index 6598e1d..1972e1e 100644 --- a/flexiapi/tests/Feature/AccountProvisioningTest.php +++ b/flexiapi/tests/Feature/AccountProvisioningTest.php @@ -179,4 +179,4 @@ class AccountProvisioningTest extends TestCase $this->get($this->route.'/auth_token/'.$authToken) ->assertStatus(404); } -} \ No newline at end of file +} diff --git a/flexiapi/tests/TestCase.php b/flexiapi/tests/TestCase.php index 029edee..e62c47c 100644 --- a/flexiapi/tests/TestCase.php +++ b/flexiapi/tests/TestCase.php @@ -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,