mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-05-07 05:53:07 +00:00
Fix FLEXIAPI-163 Complete AccountService hooks
This commit is contained in:
parent
f90851b6f2
commit
676760579d
5 changed files with 89 additions and 50 deletions
|
|
@ -15,6 +15,7 @@ v1.5
|
|||
- Fix FLEXIAPI-166 Reimplement the deprecated email validation URL
|
||||
- Fix FLEXIAPI-165 Remove for now text/vcard header constraint
|
||||
- Fix FLEXIAPI-164 Add vcards-storage endpoints
|
||||
- Fix FLEXIAPI-163 Complete AccountService hooks
|
||||
- Fix FLEXIAPI-162 Drop the aliases table and migrate the data to the phone column
|
||||
- Fix FLEXIAPI-161 Complete the Dictionary tests to cover the collection accessor
|
||||
- Fix FLEXIAPI-158 Restrict the phone number change API endpoint to return 403 if the account doesn't have a validated Account Creation Token
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ class AccountService
|
|||
}
|
||||
|
||||
if (function_exists('accountServiceAccountCreatedHook')) {
|
||||
$account->refresh();
|
||||
accountServiceAccountCreatedHook($request, $account);
|
||||
}
|
||||
|
||||
|
|
@ -172,6 +173,14 @@ class AccountService
|
|||
|
||||
$account->phone = $request->get('phone');
|
||||
$account->save();
|
||||
|
||||
if ($request->has('dictionary')) {
|
||||
$account->dictionaryEntries()->delete();
|
||||
|
||||
foreach ($request->get('dictionary') as $key => $value) {
|
||||
$account->setDictionaryEntry($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::channel('events')->info(
|
||||
|
|
@ -182,6 +191,7 @@ class AccountService
|
|||
);
|
||||
|
||||
if (function_exists('accountServiceAccountEditedHook')) {
|
||||
$account->refresh();
|
||||
accountServiceAccountEditedHook($request, $account);
|
||||
}
|
||||
|
||||
|
|
|
|||
81
flexiapi/composer.lock
generated
81
flexiapi/composer.lock
generated
|
|
@ -2511,16 +2511,16 @@
|
|||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"version": "3.27.0",
|
||||
"version": "3.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "4729745b1ab737908c7d055148c9a6b3e959832f"
|
||||
"reference": "e611adab2b1ae2e3072fa72d62c62f52c2bf1f0c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/4729745b1ab737908c7d055148c9a6b3e959832f",
|
||||
"reference": "4729745b1ab737908c7d055148c9a6b3e959832f",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/e611adab2b1ae2e3072fa72d62c62f52c2bf1f0c",
|
||||
"reference": "e611adab2b1ae2e3072fa72d62c62f52c2bf1f0c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2544,10 +2544,13 @@
|
|||
"composer/semver": "^3.0",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-ftp": "*",
|
||||
"ext-mongodb": "^1.3",
|
||||
"ext-zip": "*",
|
||||
"friendsofphp/php-cs-fixer": "^3.5",
|
||||
"google/cloud-storage": "^1.23",
|
||||
"guzzlehttp/psr7": "^2.6",
|
||||
"microsoft/azure-storage-blob": "^1.1",
|
||||
"mongodb/mongodb": "^1.2",
|
||||
"phpseclib/phpseclib": "^3.0.36",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^9.5.11|^10.0",
|
||||
|
|
@ -2585,32 +2588,22 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/thephpleague/flysystem/issues",
|
||||
"source": "https://github.com/thephpleague/flysystem/tree/3.27.0"
|
||||
"source": "https://github.com/thephpleague/flysystem/tree/3.28.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://ecologi.com/frankdejonge",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/frankdejonge",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-07T19:17:50+00:00"
|
||||
"time": "2024-05-22T10:09:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem-local",
|
||||
"version": "3.25.1",
|
||||
"version": "3.28.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem-local.git",
|
||||
"reference": "61a6a90d6e999e4ddd9ce5adb356de0939060b92"
|
||||
"reference": "13f22ea8be526ea58c2ddff9e158ef7c296e4f40"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/61a6a90d6e999e4ddd9ce5adb356de0939060b92",
|
||||
"reference": "61a6a90d6e999e4ddd9ce5adb356de0939060b92",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/13f22ea8be526ea58c2ddff9e158ef7c296e4f40",
|
||||
"reference": "13f22ea8be526ea58c2ddff9e158ef7c296e4f40",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2644,19 +2637,9 @@
|
|||
"local"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/thephpleague/flysystem-local/tree/3.25.1"
|
||||
"source": "https://github.com/thephpleague/flysystem-local/tree/3.28.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://ecologi.com/frankdejonge",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/frankdejonge",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-03-15T19:58:44+00:00"
|
||||
"time": "2024-05-06T20:05:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/mime-type-detection",
|
||||
|
|
@ -5050,16 +5033,16 @@
|
|||
},
|
||||
{
|
||||
"name": "react/promise",
|
||||
"version": "v3.1.0",
|
||||
"version": "v3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reactphp/promise.git",
|
||||
"reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c"
|
||||
"reference": "8a164643313c71354582dc850b42b33fa12a4b63"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/reactphp/promise/zipball/e563d55d1641de1dea9f5e84f3cccc66d2bfe02c",
|
||||
"reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c",
|
||||
"url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
|
||||
"reference": "8a164643313c71354582dc850b42b33fa12a4b63",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -5111,7 +5094,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/reactphp/promise/issues",
|
||||
"source": "https://github.com/reactphp/promise/tree/v3.1.0"
|
||||
"source": "https://github.com/reactphp/promise/tree/v3.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -5119,7 +5102,7 @@
|
|||
"type": "open_collective"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-16T16:21:57+00:00"
|
||||
"time": "2024-05-24T10:39:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "react/socket",
|
||||
|
|
@ -9331,16 +9314,16 @@
|
|||
},
|
||||
{
|
||||
"name": "composer/pcre",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/pcre.git",
|
||||
"reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8"
|
||||
"reference": "04229f163664973f68f38f6f73d917799168ef24"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
|
||||
"reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
|
||||
"url": "https://api.github.com/repos/composer/pcre/zipball/04229f163664973f68f38f6f73d917799168ef24",
|
||||
"reference": "04229f163664973f68f38f6f73d917799168ef24",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -9382,7 +9365,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/composer/pcre/issues",
|
||||
"source": "https://github.com/composer/pcre/tree/3.1.3"
|
||||
"source": "https://github.com/composer/pcre/tree/3.1.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -9398,7 +9381,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-03-19T10:26:25+00:00"
|
||||
"time": "2024-05-27T13:40:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/xdebug-handler",
|
||||
|
|
@ -9975,16 +9958,16 @@
|
|||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.9.2",
|
||||
"version": "3.10.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
|
||||
"reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480"
|
||||
"reference": "8f90f7a53ce271935282967f53d0894f8f1ff877"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480",
|
||||
"reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877",
|
||||
"reference": "8f90f7a53ce271935282967f53d0894f8f1ff877",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -10051,7 +10034,7 @@
|
|||
"type": "open_collective"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-23T20:25:34+00:00"
|
||||
"time": "2024-05-22T21:24:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
|
|
|
|||
|
|
@ -326,6 +326,10 @@ JSON parameters:
|
|||
* `phone` optional, a phone number, set a phone number to the account
|
||||
* `dtmf_protocol` optional, values must be `sipinfo`, `sipmessage` or `rfc2833`
|
||||
|
||||
Using this endpoint you can also set a fresh dictionnary if the parameter is set. The existing dictionary entries will be destroyed.
|
||||
|
||||
* `dictionary` optional, an associative array attached to the account, <a href="#dictionary">see also the related endpoints</a>.
|
||||
|
||||
### `GET /accounts`
|
||||
<span class="badge badge-warning">Admin</span>
|
||||
|
||||
|
|
|
|||
|
|
@ -344,8 +344,10 @@ class ApiAccountTest extends TestCase
|
|||
|
||||
$entryKey = 'foo';
|
||||
$entryValue = 'bar';
|
||||
$entryNewKey = 'new_key';
|
||||
$entryNewValue = 'new_value';
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
$result = $this->keyAuthenticated($admin)
|
||||
->json($this->method, $this->route, [
|
||||
'username' => 'john',
|
||||
'domain' => 'lennon.com',
|
||||
|
|
@ -362,6 +364,8 @@ class ApiAccountTest extends TestCase
|
|||
]
|
||||
]);
|
||||
|
||||
$accountId = $result->json('id');
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->json($this->method, $this->route, [
|
||||
'username' => 'john2',
|
||||
|
|
@ -381,6 +385,43 @@ class ApiAccountTest extends TestCase
|
|||
'algorithm' => 'SHA-256',
|
||||
'dictionary' => 'hop'
|
||||
])->assertJsonValidationErrors(['dictionary']);
|
||||
|
||||
// Account update
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->json('PUT', $this->route . '/' . $accountId, [
|
||||
'username' => 'john3',
|
||||
'password' => 'bar',
|
||||
'algorithm' => 'SHA-256',
|
||||
'dictionary' => [
|
||||
$entryNewKey => $entryNewValue
|
||||
]
|
||||
])
|
||||
->assertJsonMissing([
|
||||
'dictionary' => [
|
||||
$entryKey => $entryValue
|
||||
]
|
||||
])
|
||||
->assertJson([
|
||||
'dictionary' => [
|
||||
$entryNewKey => $entryNewValue
|
||||
]
|
||||
])
|
||||
->assertStatus(200);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->json('GET', $this->route . '/' . $accountId)
|
||||
->assertStatus(200)
|
||||
->assertJsonMissing([
|
||||
'dictionary' => [
|
||||
$entryKey => $entryValue
|
||||
]
|
||||
])
|
||||
->assertJson([
|
||||
'dictionary' => [
|
||||
$entryNewKey => $entryNewValue
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function testActivated()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue