Fixed error upon user delete with no migration id

Fixes #4162
This commit is contained in:
Dan Brown 2023-04-07 15:57:21 +01:00
parent 0a0fdd7f3e
commit fd674d10e3
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 11 additions and 1 deletions

View File

@ -197,7 +197,7 @@ class UserController extends Controller
$this->checkPermissionOrCurrentUser('users-manage', $id);
$user = $this->userRepo->getById($id);
$newOwnerId = $request->get('new_owner_id', null);
$newOwnerId = intval($request->get('new_owner_id')) ?: null;
$this->userRepo->destroy($user, $newOwnerId);

View File

@ -162,6 +162,16 @@ class UserManagementTest extends TestCase
]);
}
public function test_delete_with_empty_owner_migration_id_works()
{
$user = $this->users->editor();
$resp = $this->asAdmin()->delete("settings/users/{$user->id}", ['new_owner_id' => '']);
$resp->assertRedirect('/settings/users');
$this->assertActivityExists(ActivityType::USER_DELETE);
$this->assertSessionHas('success');
}
public function test_delete_removes_user_preferences()
{
$editor = $this->users->editor();