diff --git a/README.md b/README.md
index e101733..257a4b2 100644
--- a/README.md
+++ b/README.md
@@ -203,26 +203,6 @@ This command will set the admin role to any available Flexisip account. You need
Once one account is declared as administrator, you can directly configure the other ones using the web panel.
-### Generate External Accounts
-
-Generate `amount` accounts defined by the `group` label.
-The generated accounts will have a random username suffixed by the group name.
-
- accounts:generate-external {amount} {group}
-
-### Export External Accounts
-
-Export all the accounts defined by the `group` label.
-The command generates a JSON file containing the accounts ready to by imported as External Accounts in the current directory. A specific path can be defined using the `--o|output` optional parameter.
-
- accounts:export-to-externals {group} {--o|output=}
-
-### Import External Accounts
-
-Import accounts previously exported as a JSON file. Accounts previously imported will be skipped in the process.
-
- accounts:import-externals {file_path}
-
## Custom email templaces
Some email templates can be customized.
diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php
index bd5e081..91d0fa8 100644
--- a/flexiapi/app/Account.php
+++ b/flexiapi/app/Account.php
@@ -77,21 +77,6 @@ class Account extends Authenticatable
$builder->where('domain', config('app.sip_domain'));
});
-
- /**
- * External account handling
- */
- static::creating(function ($account) {
- if (config('app.consume_external_account_on_create') && !getAvailableExternalAccount()) {
- abort(403, 'Accounts cannot be created on the server');
- }
- });
-
- static::created(function ($account) {
- if (config('app.consume_external_account_on_create')) {
- $account->attachExternalAccount();
- }
- });
}
public function scopeSip($query, string $sip)
@@ -138,11 +123,6 @@ class Account extends Authenticatable
return $this->hasOne(ApiKey::class);
}
- public function externalAccount()
- {
- return $this->hasOne(ExternalAccount::class);
- }
-
public function contacts()
{
return $this->belongsToMany(Account::class, 'contacts', 'account_id', 'contact_id');
@@ -284,17 +264,6 @@ class Account extends Authenticatable
return ($this->activationExpiration && $this->activationExpiration->isExpired());
}
- public function attachExternalAccount(): bool
- {
- $externalAccount = getAvailableExternalAccount();
-
- if (!$externalAccount) abort(403, 'No External Account left');
-
- $externalAccount->account_id = $this->id;
- $externalAccount->used = true;
- return $externalAccount->save();
- }
-
public function generateApiKey(): ApiKey
{
$this->apiKey()->delete();
diff --git a/flexiapi/app/Console/Commands/ExportToExternalAccounts.php b/flexiapi/app/Console/Commands/ExportToExternalAccounts.php
deleted file mode 100644
index 02467cc..0000000
--- a/flexiapi/app/Console/Commands/ExportToExternalAccounts.php
+++ /dev/null
@@ -1,51 +0,0 @@
-argument('group'))
- ->with('passwords')
- ->get();
-
- if ($accounts->count() == 0) {
- $this->error('Nothing to export');
- return;
- }
-
- $this->info('Exporting '.$accounts->count().' accounts');
-
- $data = [];
-
- foreach ($accounts as $account) {
- array_push($data, [
- 'username' => $account->username,
- 'domain' => $account->domain,
- 'group' => $account->group,
- 'password' => $account->passwords->first()->password,
- 'algorithm' => $account->passwords->first()->algorithm,
- ]);
- }
-
- file_put_contents(
- $this->option('output') ?? getcwd() . '/exported_accounts.json',
- json_encode($data)
- );
-
- $this->info('Exported');
- }
-}
diff --git a/flexiapi/app/Console/Commands/GenerateExternalAccounts.php b/flexiapi/app/Console/Commands/GenerateExternalAccounts.php
deleted file mode 100644
index 553d5c2..0000000
--- a/flexiapi/app/Console/Commands/GenerateExternalAccounts.php
+++ /dev/null
@@ -1,101 +0,0 @@
- $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';
-
- $i = 0;
-
- while ($i < $this->argument('amount')) {
- $account = new Account;
- $account->username = Str::random(12);
- $account->domain = config('app.sip_domain');
- $account->activated = 1;
- $account->ip_address = '127.0.0.1';
- $account->user_agent = 'External Account Generator';
- $account->group = $this->argument('group');
- $account->created_at = Carbon::now();
- $i++;
-
- $account->push($account->toArray());
- }
-
- Account::insert($accounts->toArray());
-
- $insertedAccounts = Account::where('group', $this->argument('group'))
- ->latest()
- ->take($this->argument('amount'))
- ->get();
-
- foreach ($insertedAccounts as $account) {
- $password = new Password;
- $password->account_id = $account->id;
- $password->password = bchash($account->username, $account->resolvedRealm, Str::random(6), $algorithm);
- $password->algorithm = $algorithm;
- $passwords->push($password->only(['account_id', 'password', 'algorithm']));
- }
-
- Password::insert($passwords->toArray());
-
- $this->info($this->argument('amount') . ' accounts created under the "' . $this->argument('group') . '" group');
-
- return 0;
- }
-}
diff --git a/flexiapi/app/Console/Commands/ImportExternalAccounts.php b/flexiapi/app/Console/Commands/ImportExternalAccounts.php
deleted file mode 100644
index 598cab1..0000000
--- a/flexiapi/app/Console/Commands/ImportExternalAccounts.php
+++ /dev/null
@@ -1,68 +0,0 @@
-argument('file_path'))) {
- $this->error('The file does not exists');
- return 1;
- }
-
- $json = json_decode(file_get_contents($this->argument('file_path')));
-
- if (empty($json)) {
- $this->error('Nothing to import or incorrect file');
- return 1;
- }
-
- $existingUsernames = ExternalAccount::select('username')
- ->from('external_accounts')
- ->get()
- ->pluck('username');
- $existingCounter = 0;
- $importedCounter = 0;
-
- $externalAccounts = collect();
- foreach ($json as $account) {
- if ($existingUsernames->contains($account->username)) {
- $existingCounter++;
- continue;
- }
-
- $externalAccount = new ExternalAccount;
- $externalAccount->username = $account->username;
- $externalAccount->domain = $account->domain;
- $externalAccount->group = $account->group;
- $externalAccount->password = $account->password;
- $externalAccount->algorithm = $account->algorithm;
-
- $externalAccounts->push($externalAccount->toArray());
- $importedCounter++;
- }
-
- ExternalAccount::insert($externalAccounts->toArray());
-
- $this->info($importedCounter . ' accounts imported');
-
- if ($existingCounter > 0) {
- $this->info($existingCounter . ' accounts already in the database');
- }
-
- return 0;
- }
-}
diff --git a/flexiapi/app/ExternalAccount.php b/flexiapi/app/ExternalAccount.php
deleted file mode 100644
index 70b4747..0000000
--- a/flexiapi/app/ExternalAccount.php
+++ /dev/null
@@ -1,26 +0,0 @@
-belongsTo('App\Account');
- }
-
- public function getIdentifierAttribute()
- {
- return $this->attributes['username'].'@'.$this->attributes['domain'];
- }
-
- public function getResolvedRealmAttribute()
- {
- return $this->attributes['domain'];
- }
-}
diff --git a/flexiapi/app/Helpers/Utils.php b/flexiapi/app/Helpers/Utils.php
index 99a2f8a..cca810a 100644
--- a/flexiapi/app/Helpers/Utils.php
+++ b/flexiapi/app/Helpers/Utils.php
@@ -21,7 +21,6 @@ use Illuminate\Support\Str;
use App\Account;
use App\DigestNonce;
-use App\ExternalAccount;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Schema;
use League\CommonMark\CommonMarkConverter;
@@ -87,28 +86,9 @@ function markdownDocumentationView($view): string
);
}
-function getAvailableExternalAccount(): ?ExternalAccount
-{
- if (Schema::hasTable('external_accounts')) {
- return ExternalAccount::where('used', false)
- ->where('account_id', null)
- ->first();
- }
-
- return null;
-}
-
function publicRegistrationEnabled(): bool
{
- if (config('app.public_registration')) {
- if (config('app.consume_external_account_on_create')) {
- return (bool)getAvailableExternalAccount();
- }
-
- return true;
- }
-
- return false;
+ return (config('app.public_registration'));
}
function isRegularExpression($string): bool
diff --git a/flexiapi/app/Http/Controllers/Account/ProvisioningController.php b/flexiapi/app/Http/Controllers/Account/ProvisioningController.php
index f4cb89e..d533979 100644
--- a/flexiapi/app/Http/Controllers/Account/ProvisioningController.php
+++ b/flexiapi/app/Http/Controllers/Account/ProvisioningController.php
@@ -182,8 +182,6 @@ class ProvisioningController extends Controller
$config->appendChild($section);
if ($account) {
- $externalAccount = $account->externalAccount;
-
$section = $dom->createElement('section');
$section->setAttribute('name', 'proxy_' . $proxyConfigIndex);
@@ -204,12 +202,6 @@ class ProvisioningController extends Controller
provisioningProxyHook($section, $request, $account);
}
- if ($externalAccount) {
- $entry = $dom->createElement('entry', 'external_account');
- $entry->setAttribute('name', 'depends_on');
- $section->appendChild($entry);
- }
-
$config->appendChild($section);
$passwords = $account->passwords()->get();
@@ -249,55 +241,6 @@ class ProvisioningController extends Controller
}
$proxyConfigIndex++;
-
- // External Account handling
- if ($externalAccount) {
- $section = $dom->createElement('section');
- $section->setAttribute('name', 'proxy_' . $proxyConfigIndex);
-
- $entry = $dom->createElement('entry', '
- Identifier: {{ $account->externalAccount->identifier }}
-