Merge pull request #54109 from nextcloud/backport/53909/stable30

This commit is contained in:
Kate 2025-07-28 11:43:17 +02:00 committed by GitHub
commit b0953333be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View file

@ -536,10 +536,16 @@ class UsersController extends AUserData {
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']);

View file

@ -466,7 +466,8 @@ class UsersControllerTest extends TestCase {
$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')
@ -529,7 +530,8 @@ class UsersControllerTest extends TestCase {
$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')
@ -579,7 +581,8 @@ class UsersControllerTest extends TestCase {
$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')