Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,16 @@ public function addUser(
throw new OCSException($this->l10n->t('Required email address was not provided'), 110);
}

// Create the user
try {
$newUser = $this->userManager->createUser($userid, $password);
$this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
if (!$newUser instanceof IUser) {
// If the user is not an instance of IUser, it means the user creation failed
$this->logger->error('Failed addUser attempt: User creation failed.', ['app' => 'ocs_api']);
throw new OCSException($this->l10n->t('User creation failed'), 111);
}

$this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
foreach ($groups as $group) {
$this->groupManager->get($group)->addUser($newUser);
$this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ public function testAddUserSuccessful(): void {
$this->userManager
->expects($this->once())
->method('createUser')
->with('NewUser', 'PasswordOfTheNewUser');
->with('NewUser', 'PasswordOfTheNewUser')
->willReturn($this->createMock(IUser::class));
$this->logger
->expects($this->once())
->method('info')
Expand Down Expand Up @@ -540,7 +541,8 @@ public function testAddUserSuccessfulWithDisplayName(): void {
$this->userManager
->expects($this->once())
->method('createUser')
->with('NewUser', 'PasswordOfTheNewUser');
->with('NewUser', 'PasswordOfTheNewUser')
->willReturn($this->createMock(IUser::class));
$this->logger
->expects($this->once())
->method('info')
Expand Down Expand Up @@ -590,7 +592,8 @@ public function testAddUserSuccessfulGenerateUserID(): void {
$this->userManager
->expects($this->once())
->method('createUser')
->with($this->anything(), 'PasswordOfTheNewUser');
->with($this->anything(), 'PasswordOfTheNewUser')
->willReturn($this->createMock(IUser::class));
$this->logger
->expects($this->once())
->method('info')
Expand Down
Loading