Create an account
diff --git a/flexiapi/resources/views/account/login.blade.php b/flexiapi/resources/views/account/login.blade.php
index b0d01ec..3f45de7 100644
--- a/flexiapi/resources/views/account/login.blade.php
+++ b/flexiapi/resources/views/account/login.blade.php
@@ -28,7 +28,7 @@
@include('parts.password_recovery')
@endif
- @if (config('app.public_registration'))
+ @if (publicRegistrationEnabled())
diff --git a/flexiapi/resources/views/admin/account/index.blade.php b/flexiapi/resources/views/admin/account/index.blade.php
index 6342c3f..a41e0d8 100644
--- a/flexiapi/resources/views/admin/account/index.blade.php
+++ b/flexiapi/resources/views/admin/account/index.blade.php
@@ -42,14 +42,17 @@
+ @if ($account->externalAccount)
+ EA
+ @endif
@if ($account->email)
Email
@endif
@if ($account->activated)
- Activated
+ Act.
@endif
@if ($account->admin)
- Admin
+ Adm.
@endif
@if ($account->sha256Password)
SHA256
diff --git a/flexiapi/resources/views/admin/account/show.blade.php b/flexiapi/resources/views/admin/account/show.blade.php
index 2fa1763..b0e4d91 100644
--- a/flexiapi/resources/views/admin/account/show.blade.php
+++ b/flexiapi/resources/views/admin/account/show.blade.php
@@ -22,6 +22,7 @@
Email: {{ $account->email }}
DTMF Protocol: @if ($account->dtmf_protocol) {{ $account->resolvedDtmfProtocol }}@endif
@if ($account->alias)Phone number: {{ $account->phone }} @endif
+ @if ($account->group)Group: {{ $account->group }} @endif
@if ($account->display_name)Display name: {{ $account->display_name }} @endif
@@ -45,6 +46,16 @@
Not Admin Add admin role
@endif
+External Account
+
+@if ($account->externalAccount)
+
+ Identifier: {{ $account->externalAccount->identifier }}
+
+@else
+ Attach an External Account ({{ $external_accounts_count}} left)
+@endif
+
Contacts
diff --git a/flexiapi/resources/views/admin/statistics/parts/columns.blade.php b/flexiapi/resources/views/admin/statistics/parts/columns.blade.php
index b62f166..67e1585 100644
--- a/flexiapi/resources/views/admin/statistics/parts/columns.blade.php
+++ b/flexiapi/resources/views/admin/statistics/parts/columns.blade.php
@@ -1,12 +1,12 @@
-
-
-
-
\ No newline at end of file
diff --git a/flexiapi/resources/views/layouts/main.blade.php b/flexiapi/resources/views/layouts/main.blade.php
index 65b64d5..a8e8676 100644
--- a/flexiapi/resources/views/layouts/main.blade.php
+++ b/flexiapi/resources/views/layouts/main.blade.php
@@ -17,7 +17,7 @@
- @if (config('app.public_registration'))
+ @if (publicRegistrationEnabled())
-
Register
diff --git a/flexiapi/routes/web.php b/flexiapi/routes/web.php
index 349c6e2..afa0a73 100644
--- a/flexiapi/routes/web.php
+++ b/flexiapi/routes/web.php
@@ -48,7 +48,7 @@ Route::get('provisioning/auth_token/{auth_token}', 'Account\ProvisioningControll
Route::get('provisioning/qrcode/{provisioning_token}', 'Account\ProvisioningController@qrcode')->name('provisioning.qrcode');
Route::get('provisioning/{provisioning_token?}', 'Account\ProvisioningController@show')->name('provisioning.show');
-if (config('app.public_registration')) {
+if (publicRegistrationEnabled()) {
if (config('app.phone_authentication')) {
Route::get('register/phone', 'Account\RegisterController@registerPhone')->name('account.register.phone');
Route::post('register/phone', 'Account\RegisterController@storePhone')->name('account.store.phone');
@@ -118,6 +118,8 @@ if (config('app.web_panel')) {
Route::get('admin/accounts/{account}/activate', 'Admin\AccountController@activate')->name('admin.account.activate');
Route::get('admin/accounts/{account}/deactivate', 'Admin\AccountController@deactivate')->name('admin.account.deactivate');
+ Route::get('admin/accounts/{account}/external_account/attach', 'Admin\AccountController@attachExternalAccount')->name('admin.account.external_account.attach');
+
Route::get('admin/accounts/{account}/admin', 'Admin\AccountController@admin')->name('admin.account.admin');
Route::get('admin/accounts/{id}/unadmin', 'Admin\AccountController@unadmin')->name('admin.account.unadmin');
diff --git a/flexiapi/tests/Feature/ExternalAccountTest.php b/flexiapi/tests/Feature/ExternalAccountTest.php
new file mode 100644
index 0000000..92fb9a5
--- /dev/null
+++ b/flexiapi/tests/Feature/ExternalAccountTest.php
@@ -0,0 +1,83 @@
+.
+*/
+
+namespace Tests\Feature;
+
+use App\Admin;
+use App\Account;
+use App\ExternalAccount;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Tests\TestCase;
+
+class ExternalAccountTest extends TestCase
+{
+ use RefreshDatabase;
+
+ protected $route = '/api/accounts';
+ protected $provisioningRoute = '/provisioning/me';
+ protected $method = 'POST';
+
+ public function testExternalAccountAttachOnCreate()
+ {
+ $admin = Admin::factory()->create();
+ $password = $admin->account->passwords()->first();
+ $password->account->generateApiKey();
+ $password->account->save();
+
+ config()->set('app.consume_external_account_on_create', true);
+
+ // Seed an ExternalAccount
+ $externalAccount = ExternalAccount::factory()->create();
+ $externalAccount->save();
+
+ $response = $this->keyAuthenticated($password->account)
+ ->json($this->method, $this->route, [
+ 'username' => 'test',
+ 'domain' => 'example.com',
+ 'algorithm' => 'SHA-256',
+ 'password' => '123456',
+ 'activated' => true,
+ ]);
+
+ $response->assertStatus(200);
+
+ // No ExternalAccount left
+ $response = $this->keyAuthenticated($password->account)
+ ->json($this->method, $this->route, [
+ 'username' => 'test2',
+ 'domain' => 'example.com',
+ 'algorithm' => 'SHA-256',
+ 'password' => '123456',
+ ]);
+
+ $response->assertStatus(403);
+
+ $createdAccount = Account::where('username', 'test')->first();
+ $createdAccount->generateApiKey();
+ $createdAccount->save();
+
+ $response = $this->keyAuthenticated($createdAccount)
+ ->get($this->provisioningRoute)
+ ->assertStatus(200)
+ ->assertHeader('Content-Type', 'application/xml')
+ ->assertSee('ha1')
+ ->assertSee('idkey')
+ ->assertSee('depends_on');
+ }
+}
diff --git a/flexiapi/tests/TestCase.php b/flexiapi/tests/TestCase.php
index 51fdf41..7449ca0 100644
--- a/flexiapi/tests/TestCase.php
+++ b/flexiapi/tests/TestCase.php
@@ -21,7 +21,6 @@ namespace Tests;
use App\Password;
use App\Account;
-use App\Helpers\Utils;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
@@ -59,7 +58,7 @@ abstract class TestCase extends BaseTestCase
$challenge = \substr($response->headers->get('www-authenticate'), 7);
$extractedChallenge = $this->extractAuthenticateHeader($challenge);
- $cnonce = Utils::generateNonce();
+ $cnonce = generateNonce();
$A1 = $password->password;
$A2 = hash($hash, $this->method . ':' . $this->route);
diff --git a/flexisip-account-manager.spec b/flexisip-account-manager.spec
index 2e6335b..d1c6bad 100644
--- a/flexisip-account-manager.spec
+++ b/flexisip-account-manager.spec
@@ -8,7 +8,7 @@
#%define _datadir %{_datarootdir}
#%define _docdir %{_datadir}/doc
-%define build_number 142
+%define build_number 143
%define var_dir /var/opt/belledonne-communications
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager
|