summaryrefslogtreecommitdiffstats
path: root/settings/Controller/UsersController.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-02-15 12:17:55 -0600
committerMorris Jobke <hey@morrisjobke.de>2017-02-15 17:45:38 -0600
commit2e88bec14bb9cee82c1f3e5479c081eeadd89be5 (patch)
treedb530d28c2d457379c9e3f5e22d7aa19cff1ac2b /settings/Controller/UsersController.php
parentc3fe8f6cf27f45d3fbcdc625ba547e3736edd07a (diff)
downloadnextcloud-server-2e88bec14bb9cee82c1f3e5479c081eeadd89be5.tar.gz
nextcloud-server-2e88bec14bb9cee82c1f3e5479c081eeadd89be5.zip
Fix setup issue and refine error messages
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'settings/Controller/UsersController.php')
-rw-r--r--settings/Controller/UsersController.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php
index b81b0f3ee91..fb5e6af04a8 100644
--- a/settings/Controller/UsersController.php
+++ b/settings/Controller/UsersController.php
@@ -379,6 +379,21 @@ class UsersController extends Controller {
);
}
+ $generatedPassword = false;
+ if ($password === '') {
+ if ($email === '') {
+ return new DataResponse(
+ array(
+ 'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.')
+ ),
+ Http::STATUS_UNPROCESSABLE_ENTITY
+ );
+ }
+
+ $password = $this->secureRandom->generate(32);
+ $generatedPassword = true;
+ }
+
try {
$user = $this->userManager->createUser($username, $password);
} catch (\Exception $exception) {
@@ -411,7 +426,7 @@ class UsersController extends Controller {
if($email !== '') {
$user->setEMailAddress($email);
- if ($this->config->getAppValue('core', 'umgmt_send_passwordlink', 'false') === 'true') {
+ if ($generatedPassword) {
$token = $this->secureRandom->generate(
21,
ISecureRandom::CHAR_DIGITS .
@@ -431,7 +446,7 @@ class UsersController extends Controller {
// data for the mail template
$mailData = array(
'username' => $username,
- 'url' =>$link
+ 'url' => $link
);
$mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');