diff --git a/flexiapi/app/Http/Requests/UpdateAccountRequest.php b/flexiapi/app/Http/Requests/UpdateAccountRequest.php index da381bc..ec507e1 100644 --- a/flexiapi/app/Http/Requests/UpdateAccountRequest.php +++ b/flexiapi/app/Http/Requests/UpdateAccountRequest.php @@ -30,13 +30,13 @@ class UpdateAccountRequest extends FormRequest new SIPUsername, Rule::unique('accounts', 'username')->where(function ($query) { $query->where('domain', resolveDomain($this)); - })->ignore($this->route('account_id'), 'id'), + })->ignore($this->route('id'), 'id'), 'filled', ], 'email' => [ 'nullable', 'email', - config('app.account_email_unique') ? Rule::unique('accounts', 'email')->ignore($this->route('account_id')) : null + config('app.account_email_unique') ? Rule::unique('accounts', 'email')->ignore($this->route('id')) : null ], 'role' => 'in:admin,end_user', 'dtmf_protocol' => 'nullable|in:' . Account::dtmfProtocolsRule(), @@ -44,8 +44,8 @@ class UpdateAccountRequest extends FormRequest 'nullable', Rule::unique('accounts', 'username')->where(function ($query) { $query->where('domain', resolveDomain($this)); - })->ignore($this->route('account_id'), 'id'), - Rule::unique('aliases', 'alias')->ignore($this->route('account_id'), 'account_id'), + })->ignore($this->route('id'), 'id'), + Rule::unique('aliases', 'alias')->ignore($this->route('id'), 'account_id'), new WithoutSpaces, 'starts_with:+' ] ]; diff --git a/flexiapi/tests/Feature/ApiAccountTest.php b/flexiapi/tests/Feature/ApiAccountTest.php index 48445ad..6606757 100644 --- a/flexiapi/tests/Feature/ApiAccountTest.php +++ b/flexiapi/tests/Feature/ApiAccountTest.php @@ -618,6 +618,7 @@ class ApiAccountTest extends TestCase $username = 'changed'; $algorithm = 'MD5'; $password = 'other'; + $newDisplayName = 'new_display_name'; $this->keyAuthenticated($admin->account) ->json('PUT', $this->route . '/1234') @@ -629,6 +630,15 @@ class ApiAccountTest extends TestCase ]) ->assertStatus(422); + $this->keyAuthenticated($admin->account) + ->json('PUT', $this->route . '/' . $account->id, [ + 'username' => $username, + 'algorithm' => $algorithm, + 'password' => $password, + 'display_name' => $newDisplayName + ]) + ->assertStatus(200); + $this->keyAuthenticated($admin->account) ->json('PUT', $this->route . '/' . $account->id, [ 'username' => $username, @@ -639,7 +649,8 @@ class ApiAccountTest extends TestCase $this->assertDatabaseHas('accounts', [ 'id' => $account->id, - 'username' => $username + 'username' => $username, + 'display_name' => null ]); $this->assertDatabaseHas('passwords', [