@@ -133,8 +133,12 @@ public function create(Request $request, Response $response, $args)
133133 }
134134
135135 $ data ['flag_verified ' ] = 1 ;
136- // Set password as empty on initial creation. We will then send email so new user can set it themselves via a verification token
137- $ data ['password ' ] = '' ;
136+ if (!isset ($ data ['password ' ])) {
137+ // Set password as empty on initial creation. We will then send email so new user can set it themselves via a verification token
138+ $ data ['password ' ] = '' ;
139+ } else {
140+ $ data ['password ' ] = Password::hash ($ data ['password ' ]);
141+ }
138142
139143 // All checks passed! log events/activities, create user, and send verification email (if required)
140144 // Begin transaction - DB will be rolled back if an exception occurs
@@ -162,18 +166,21 @@ public function create(Request $request, Response $response, $args)
162166 // Try to generate a new password request
163167 $ passwordRequest = $ this ->ci ->repoPasswordReset ->create ($ user , $ config ['password_reset.timeouts.create ' ]);
164168
165- // Create and send welcome email with password set link
166- $ message = new TwigMailMessage ($ this ->ci ->view , 'mail/password-create.html.twig ' );
169+ // If the password_mode is manual, do not send an email to set it. Else, send the email.
170+ if (!isset ($ data ['value ' ])) {
171+ // Create and send welcome email with password set link
172+ $ message = new TwigMailMessage ($ this ->ci ->view , 'mail/password-create.html.twig ' );
167173
168- $ message ->from ($ config ['address_book.admin ' ])
174+ $ message ->from ($ config ['address_book.admin ' ])
169175 ->addEmailRecipient (new EmailRecipient ($ user ->email , $ user ->full_name ))
170176 ->addParams ([
171177 'user ' => $ user ,
172178 'create_password_expiration ' => $ config ['password_reset.timeouts.create ' ] / 3600 . ' hours ' ,
173179 'token ' => $ passwordRequest ->getToken (),
174180 ]);
175181
176- $ this ->ci ->mailer ->send ($ message );
182+ $ this ->ci ->mailer ->send ($ message );
183+ }
177184
178185 $ ms ->addMessageTranslated ('success ' , 'USER.CREATED ' , $ data );
179186 });
@@ -694,7 +701,7 @@ public function getModalEdit(Request $request, Response $response, $args)
694701
695702 // Generate form
696703 $ fields = [
697- 'hidden ' => ['theme ' ],
704+ 'hidden ' => ['theme ' , ' password ' ],
698705 'disabled ' => ['user_name ' ],
699706 ];
700707
0 commit comments