mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Fix FLEXIAPI-415 Add endpoints to activate/deactivate phone countries
This commit is contained in:
parent
25ddd330c1
commit
d179d0f6df
4 changed files with 57 additions and 4 deletions
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\PhoneCountry;
|
||||||
|
|
||||||
|
class PhoneCountryController extends Controller
|
||||||
|
{
|
||||||
|
public function activate(string $code)
|
||||||
|
{
|
||||||
|
$phoneCountry = PhoneCountry::where('code', $code)->firstOrFail();
|
||||||
|
return PhoneCountry::where('country_code', $phoneCountry->country_code)->update(['activated' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deactivate(string $code)
|
||||||
|
{
|
||||||
|
$phoneCountry = PhoneCountry::where('code', $code)->firstOrFail();
|
||||||
|
return PhoneCountry::where('country_code', $phoneCountry->country_code)->update(['activated' => false]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -77,6 +77,15 @@ Return the list of Phone Countries and their current status.
|
||||||
|
|
||||||
If a country is deactivated all the new submitted phones submitted on the platform will be blocked.
|
If a country is deactivated all the new submitted phones submitted on the platform will be blocked.
|
||||||
|
|
||||||
|
### `POST /phone_countries/{code}/activate`
|
||||||
|
<span class="badge badge-error">Super Admin</span>
|
||||||
|
|
||||||
|
Activate a Phone Country
|
||||||
|
|
||||||
|
### `POST /phone_countries/{code}/deactivate`
|
||||||
|
<span class="badge badge-error">Super Admin</span>
|
||||||
|
|
||||||
|
Deactivate a Phone Country
|
||||||
|
|
||||||
@include('api.documentation.statistics')
|
@include('api.documentation.statistics')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ use App\Http\Controllers\Api\Admin\Account\TypeController;
|
||||||
use App\Http\Controllers\Api\Admin\AccountController as AdminAccountController;
|
use App\Http\Controllers\Api\Admin\AccountController as AdminAccountController;
|
||||||
use App\Http\Controllers\Api\Admin\ExternalAccountController;
|
use App\Http\Controllers\Api\Admin\ExternalAccountController;
|
||||||
use App\Http\Controllers\Api\Admin\MessageController;
|
use App\Http\Controllers\Api\Admin\MessageController;
|
||||||
|
use App\Http\Controllers\Api\Admin\PhoneCountryController as AdminPhoneCountryController;
|
||||||
use App\Http\Controllers\Api\Admin\Space\CardDavServerController;
|
use App\Http\Controllers\Api\Admin\Space\CardDavServerController;
|
||||||
use App\Http\Controllers\Api\Admin\Space\ContactsListController;
|
use App\Http\Controllers\Api\Admin\Space\ContactsListController;
|
||||||
use App\Http\Controllers\Api\Admin\Space\EmailServerController;
|
use App\Http\Controllers\Api\Admin\Space\EmailServerController;
|
||||||
|
|
@ -122,6 +123,9 @@ Route::group(['middleware' => ['auth.jwt', 'auth.digest_or_key', 'auth.check_blo
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::apiResource('spaces/{domain}/carddavs', CardDavServerController::class);
|
Route::apiResource('spaces/{domain}/carddavs', CardDavServerController::class);
|
||||||
|
|
||||||
|
Route::post('phone_countries/{code}/activate', [AdminPhoneCountryController::class, 'activate']);
|
||||||
|
Route::post('phone_countries/{code}/deactivate', [AdminPhoneCountryController::class, 'deactivate']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Account creation token
|
// Account creation token
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ class ApiPhoneCountryTest extends TestCase
|
||||||
{
|
{
|
||||||
$account = Account::factory()->withConsumedAccountCreationToken()->create();
|
$account = Account::factory()->withConsumedAccountCreationToken()->create();
|
||||||
$account->generateUserApiKey();
|
$account->generateUserApiKey();
|
||||||
|
$superAdmin = Account::factory()->superAdmin()->create();
|
||||||
|
$superAdmin->generateUserApiKey();
|
||||||
|
|
||||||
$frenchPhoneNumber = '+33612121212';
|
$frenchPhoneNumber = '+33612121212';
|
||||||
$dutchPhoneNumber = '+31612121212';
|
$dutchPhoneNumber = '+31612121212';
|
||||||
|
|
@ -50,18 +52,24 @@ class ApiPhoneCountryTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->keyAuthenticated($account)
|
$this->keyAuthenticated($account)
|
||||||
->json($this->method, $this->routeChangePhone.'/request', [
|
->json($this->method, $this->routeChangePhone . '/request', [
|
||||||
'phone' => $frenchPhoneNumber
|
'phone' => $frenchPhoneNumber
|
||||||
])
|
])
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
$this->keyAuthenticated($account)
|
$this->keyAuthenticated($account)
|
||||||
->json($this->method, $this->routeChangePhone.'/request', [
|
->json($this->method, $this->routeChangePhone . '/request', [
|
||||||
'phone' => $dutchPhoneNumber
|
'phone' => $dutchPhoneNumber
|
||||||
])
|
])
|
||||||
->assertJsonValidationErrors(['phone']);
|
->assertJsonValidationErrors(['phone']);
|
||||||
|
|
||||||
PhoneCountry::where('code', 'NL')->update(['activated' => true]);
|
$this->keyAuthenticated($account)
|
||||||
|
->post($this->route . '/NL/activate')
|
||||||
|
->assertStatus(403);
|
||||||
|
|
||||||
|
$this->keyAuthenticated($superAdmin)
|
||||||
|
->post($this->route . '/NL/activate')
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
$this->get($this->route)
|
$this->get($this->route)
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
|
|
@ -71,9 +79,20 @@ class ApiPhoneCountryTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->keyAuthenticated($account)
|
$this->keyAuthenticated($account)
|
||||||
->json($this->method, $this->routeChangePhone.'/request', [
|
->json($this->method, $this->routeChangePhone . '/request', [
|
||||||
'phone' => $dutchPhoneNumber
|
'phone' => $dutchPhoneNumber
|
||||||
])
|
])
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
|
$this->keyAuthenticated($superAdmin)
|
||||||
|
->post($this->route . '/NL/deactivate')
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
$this->get($this->route)
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'code' => 'NL',
|
||||||
|
'activated' => false
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue