mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
fix(provisioning_api): catch failed user creation
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
parent
19009b3620
commit
74d6494290
2 changed files with 13 additions and 4 deletions
|
|
@ -542,10 +542,16 @@ class UsersController extends AUserDataOCSController {
|
|||
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']);
|
||||
|
|
|
|||
|
|
@ -452,7 +452,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')
|
||||
|
|
@ -517,7 +518,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')
|
||||
|
|
@ -567,7 +569,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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue