Merge pull request #23203 from nextcloud/backport/23182/stable20
[stable20] Fix the user email issue while creating a user
This commit is contained in:
commit
20524cff33
|
@ -337,8 +337,9 @@ class UsersController extends AUserData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send new user mail only if a mail is set
|
// Send new user mail only if a mail is set
|
||||||
if ($email !== '' && $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') {
|
if ($email !== '') {
|
||||||
$newUser->setEMailAddress($email);
|
$newUser->setEMailAddress($email);
|
||||||
|
if ($this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') {
|
||||||
try {
|
try {
|
||||||
$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
|
$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
|
||||||
$this->newUserMailHelper->sendMail($newUser, $emailTemplate);
|
$this->newUserMailHelper->sendMail($newUser, $emailTemplate);
|
||||||
|
@ -352,6 +353,7 @@ class UsersController extends AUserData {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new DataResponse(['id' => $userid]);
|
return new DataResponse(['id' => $userid]);
|
||||||
} catch (HintException $e) {
|
} catch (HintException $e) {
|
||||||
|
|
|
@ -500,9 +500,13 @@ class UsersControllerTest extends TestCase {
|
||||||
->method('userExists')
|
->method('userExists')
|
||||||
->with('NewUser')
|
->with('NewUser')
|
||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
|
$newUser = $this->createMock(IUser::class);
|
||||||
|
$newUser->expects($this->once())
|
||||||
|
->method('setEMailAddress');
|
||||||
$this->userManager
|
$this->userManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('createUser');
|
->method('createUser')
|
||||||
|
->willReturn($newUser);
|
||||||
$this->logger
|
$this->logger
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('info')
|
->method('info')
|
||||||
|
|
Loading…
Reference in New Issue