You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/Command/User/Add.php
+27-31Lines changed: 27 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@
29
29
useOC\Files\Filesystem;
30
30
useOCA\Settings\Mailer\NewUserMailHelper;
31
31
useOCP\EventDispatcher\IEventDispatcher;
32
-
useOCP\IConfig;
32
+
useOCP\IAppConfig;
33
33
useOCP\IGroup;
34
34
useOCP\IGroupManager;
35
35
useOCP\IUser;
@@ -50,15 +50,15 @@ public function __construct(
50
50
protectedIUserManager$userManager,
51
51
protectedIGroupManager$groupManager,
52
52
protectedIMailer$mailer,
53
-
privateIConfig$config,
53
+
privateIAppConfig$appConfig,
54
54
privateNewUserMailHelper$mailHelper,
55
55
privateIEventDispatcher$eventDispatcher,
56
56
privateISecureRandom$secureRandom,
57
57
) {
58
58
parent::__construct();
59
59
}
60
60
61
-
protectedfunctionconfigure() {
61
+
protectedfunctionconfigure(): void {
62
62
$this
63
63
->setName('user:add')
64
64
->setDescription('adds an account')
@@ -73,6 +73,12 @@ protected function configure() {
73
73
InputOption::VALUE_NONE,
74
74
'read password from environment variable OC_PASS'
75
75
)
76
+
->addOption(
77
+
'generate-password',
78
+
null,
79
+
InputOption::VALUE_NONE,
80
+
'Generate a secure password. A welcome email with a reset link will be sent to the user via an email if --email option and newUser.sendEmail config are set'
81
+
)
76
82
->addOption(
77
83
'display-name',
78
84
null,
@@ -89,7 +95,7 @@ protected function configure() {
89
95
'email',
90
96
null,
91
97
InputOption::VALUE_REQUIRED,
92
-
'When set, users may register using the default E-Mail verification workflow'
98
+
'When set, users may register using the default email verification workflow'
93
99
);
94
100
}
95
101
@@ -101,19 +107,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
101
107
}
102
108
103
109
$password = '';
104
-
$sendPasswordEmail = false;
105
-
106
-
$email = $input->getOption('email');
107
-
if (!empty($email)) {
108
-
if (!$this->mailer->validateMailAddress($email)) {
109
-
$output->writeln(\sprintf(
110
-
'<error>The given E-Mail address "%s" is invalid</error>',
111
-
$email,
112
-
));
113
-
114
-
return1;
115
-
}
116
-
}
117
110
118
111
// Setup password.
119
112
if ($input->getOption('password-from-env')) {
@@ -123,13 +116,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
123
116
$output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>');
0 commit comments