mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Fix FLEXIAPI-150 Use the same account_id parameter for both API and Web routes
This commit is contained in:
parent
8fe5761859
commit
2e9455ef11
3 changed files with 39 additions and 39 deletions
|
|
@ -43,9 +43,9 @@ class AccountController extends Controller
|
||||||
return Account::without(['passwords', 'admin'])->paginate(20);
|
return Account::without(['passwords', 'admin'])->paginate(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id)
|
public function show($accountId)
|
||||||
{
|
{
|
||||||
return Account::without(['passwords', 'admin'])->findOrFail($id)->makeVisible(['confirmation_key', 'provisioning_token']);
|
return Account::without(['passwords', 'admin'])->findOrFail($accountId)->makeVisible(['confirmation_key', 'provisioning_token']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search(string $sip)
|
public function search(string $sip)
|
||||||
|
|
@ -58,9 +58,9 @@ class AccountController extends Controller
|
||||||
return Account::where('email', $email)->firstOrFail();
|
return Account::where('email', $email)->firstOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($accountId)
|
||||||
{
|
{
|
||||||
$account = Account::findOrFail($id);
|
$account = Account::findOrFail($accountId);
|
||||||
|
|
||||||
if (!$account->hasTombstone()) {
|
if (!$account->hasTombstone()) {
|
||||||
$tombstone = new AccountTombstone;
|
$tombstone = new AccountTombstone;
|
||||||
|
|
@ -74,9 +74,9 @@ class AccountController extends Controller
|
||||||
$account->delete();
|
$account->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activate(int $id)
|
public function activate(int $accountId)
|
||||||
{
|
{
|
||||||
$account = Account::findOrFail($id);
|
$account = Account::findOrFail($accountId);
|
||||||
$account->activated = true;
|
$account->activated = true;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
|
|
@ -85,9 +85,9 @@ class AccountController extends Controller
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deactivate(int $id)
|
public function deactivate(int $accountId)
|
||||||
{
|
{
|
||||||
$account = Account::findOrFail($id);
|
$account = Account::findOrFail($accountId);
|
||||||
$account->activated = false;
|
$account->activated = false;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
|
|
@ -96,9 +96,9 @@ class AccountController extends Controller
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function block(int $id)
|
public function block(int $accountId)
|
||||||
{
|
{
|
||||||
$account = Account::findOrFail($id);
|
$account = Account::findOrFail($accountId);
|
||||||
$account->blocked = true;
|
$account->blocked = true;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
|
|
@ -107,9 +107,9 @@ class AccountController extends Controller
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unblock(int $id)
|
public function unblock(int $accountId)
|
||||||
{
|
{
|
||||||
$account = Account::findOrFail($id);
|
$account = Account::findOrFail($accountId);
|
||||||
$account->blocked = false;
|
$account->blocked = false;
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
|
|
@ -118,9 +118,9 @@ class AccountController extends Controller
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provision(int $id)
|
public function provision(int $accountId)
|
||||||
{
|
{
|
||||||
$account = Account::findOrFail($id);
|
$account = Account::findOrFail($accountId);
|
||||||
$account->provision();
|
$account->provision();
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
|
|
@ -164,43 +164,43 @@ class AccountController extends Controller
|
||||||
return $account->makeVisible(['confirmation_key', 'provisioning_token']);
|
return $account->makeVisible(['confirmation_key', 'provisioning_token']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function typeAdd(int $id, int $typeId)
|
public function typeAdd(int $accountId, int $typeId)
|
||||||
{
|
{
|
||||||
if (Account::findOrFail($id)->types()->pluck('id')->contains($typeId)) {
|
if (Account::findOrFail($accountId)->types()->pluck('id')->contains($typeId)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AccountType::findOrFail($typeId)) {
|
if (AccountType::findOrFail($typeId)) {
|
||||||
return Account::findOrFail($id)->types()->attach($typeId);
|
return Account::findOrFail($accountId)->types()->attach($typeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function typeRemove(int $id, int $typeId)
|
public function typeRemove(int $accountId, int $typeId)
|
||||||
{
|
{
|
||||||
if (!Account::findOrFail($id)->types()->pluck('id')->contains($typeId)) {
|
if (!Account::findOrFail($accountId)->types()->pluck('id')->contains($typeId)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Account::findOrFail($id)->types()->detach($typeId);
|
return Account::findOrFail($accountId)->types()->detach($typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function contactsListAdd(int $id, int $contactsListId)
|
public function contactsListAdd(int $accountId, int $contactsListId)
|
||||||
{
|
{
|
||||||
if (Account::findOrFail($id)->contactsLists()->pluck('id')->contains($contactsListId)) {
|
if (Account::findOrFail($accountId)->contactsLists()->pluck('id')->contains($contactsListId)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContactsList::findOrFail($contactsListId)) {
|
if (ContactsList::findOrFail($contactsListId)) {
|
||||||
return Account::findOrFail($id)->contactsLists()->attach($contactsListId);
|
return Account::findOrFail($accountId)->contactsLists()->attach($contactsListId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function contactsListRemove(int $id, int $contactsListId)
|
public function contactsListRemove(int $accountId, int $contactsListId)
|
||||||
{
|
{
|
||||||
if (!Account::findOrFail($id)->contactsLists()->pluck('id')->contains($contactsListId)) {
|
if (!Account::findOrFail($accountId)->contactsLists()->pluck('id')->contains($contactsListId)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Account::findOrFail($id)->contactsLists()->detach($contactsListId);
|
return Account::findOrFail($accountId)->contactsLists()->detach($contactsListId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class UpdateAccountRequest extends FormRequest
|
||||||
new SIPUsername,
|
new SIPUsername,
|
||||||
Rule::unique('accounts', 'username')->where(function ($query) {
|
Rule::unique('accounts', 'username')->where(function ($query) {
|
||||||
$query->where('domain', resolveDomain($this));
|
$query->where('domain', resolveDomain($this));
|
||||||
})->ignore($this->route('id'), 'id'),
|
})->ignore($this->route('account_id'), 'id'),
|
||||||
'filled',
|
'filled',
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
|
|
|
||||||
|
|
@ -90,25 +90,25 @@ Route::group(['middleware' => ['auth.digest_or_key', 'auth.check_blocked']], fun
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
Route::prefix('accounts')->controller(AdminAccountController::class)->group(function () {
|
Route::prefix('accounts')->controller(AdminAccountController::class)->group(function () {
|
||||||
Route::post('{id}/activate', 'activate');
|
Route::post('{account_id}/activate', 'activate');
|
||||||
Route::post('{id}/deactivate', 'deactivate');
|
Route::post('{account_id}/deactivate', 'deactivate');
|
||||||
Route::post('{id}/block', 'block');
|
Route::post('{account_id}/block', 'block');
|
||||||
Route::post('{id}/unblock', 'unblock');
|
Route::post('{account_id}/unblock', 'unblock');
|
||||||
Route::get('{id}/provision', 'provision');
|
Route::get('{account_id}/provision', 'provision');
|
||||||
|
|
||||||
Route::post('/', 'store');
|
Route::post('/', 'store');
|
||||||
Route::put('{id}', 'update');
|
Route::put('{account_id}', 'update');
|
||||||
Route::get('/', 'index');
|
Route::get('/', 'index');
|
||||||
Route::get('{id}', 'show');
|
Route::get('{account_id}', 'show');
|
||||||
Route::delete('{id}', 'destroy');
|
Route::delete('{account_id}', 'destroy');
|
||||||
Route::get('{sip}/search', 'search');
|
Route::get('{sip}/search', 'search');
|
||||||
Route::get('{email}/search-by-email', 'searchByEmail');
|
Route::get('{email}/search-by-email', 'searchByEmail');
|
||||||
|
|
||||||
Route::post('{id}/types/{type_id}', 'typeAdd');
|
Route::post('{account_id}/types/{type_id}', 'typeAdd');
|
||||||
Route::delete('{id}/types/{type_id}', 'typeRemove');
|
Route::delete('{account_id}/types/{type_id}', 'typeRemove');
|
||||||
|
|
||||||
Route::post('{id}/contacts_lists/{contacts_list_id}', 'contactsListAdd');
|
Route::post('{account_id}/contacts_lists/{contacts_list_id}', 'contactsListAdd');
|
||||||
Route::delete('{id}/contacts_lists/{contacts_list_id}', 'contactsListRemove');
|
Route::delete('{account_id}/contacts_lists/{contacts_list_id}', 'contactsListRemove');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Account contacts
|
// Account contacts
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue