@@ -118,13 +118,13 @@ public function create($request, $response, $args)
118118 }
119119
120120 $ data ['flag_verified ' ] = 1 ;
121- if (!isset ($ data ['value ' ])){
122- // Set password as empty on initial creation. We will then send email so new user can set it themselves via a verification token
123- $ data ['password ' ] = '' ;
124- }else {
125- $ data ['password ' ] = Password::hash ($ data ['value ' ]);
126- }
127-
121+ if (!isset ($ data ['value ' ])){
122+ // Set password as empty on initial creation. We will then send email so new user can set it themselves via a verification token
123+ $ data ['password ' ] = '' ;
124+ }else {
125+ $ data ['password ' ] = Password::hash ($ data ['value ' ]);
126+ }
127+
128128 // All checks passed! log events/activities, create user, and send verification email (if required)
129129 // Begin transaction - DB will be rolled back if an exception occurs
130130 Capsule::transaction ( function () use ($ classMapper , $ data , $ ms , $ config , $ currentUser ) {
@@ -139,7 +139,7 @@ public function create($request, $response, $args)
139139 'type ' => 'account_create ' ,
140140 'user_id ' => $ currentUser ->id
141141 ]);
142-
142+
143143 // Load default roles
144144 $ defaultRoleSlugs = $ classMapper ->staticMethod ('role ' , 'getDefaultSlugs ' );
145145 $ defaultRoles = $ classMapper ->staticMethod ('role ' , 'whereIn ' , 'slug ' , $ defaultRoleSlugs )->get ();
@@ -151,22 +151,22 @@ public function create($request, $response, $args)
151151 // Try to generate a new password request
152152 $ passwordRequest = $ this ->ci ->repoPasswordReset ->create ($ user , $ config ['password_reset.timeouts.create ' ]);
153153
154- // If the password_mode is manual, do not send an email to set it. Else, send the email.
155- if (!isset ($ data ['value ' ])){
156- // Create and send welcome email with password set link
157- $ message = new TwigMailMessage ($ this ->ci ->view , 'mail/password-create.html.twig ' );
158-
159- $ message ->from ($ config ['address_book.admin ' ])
160- ->addEmailRecipient (new EmailRecipient ($ user ->email , $ user ->full_name ))
161- ->addParams ([
162- 'user ' => $ user ,
163- 'create_password_expiration ' => $ config ['password_reset.timeouts.create ' ] / 3600 . ' hours ' ,
164- 'token ' => $ passwordRequest ->getToken ()
165- ]);
166-
167- $ this ->ci ->mailer ->send ($ message );
168- }
169-
154+ // If the password_mode is manual, do not send an email to set it. Else, send the email.
155+ if (!isset ($ data ['value ' ])){
156+ // Create and send welcome email with password set link
157+ $ message = new TwigMailMessage ($ this ->ci ->view , 'mail/password-create.html.twig ' );
158+
159+ $ message ->from ($ config ['address_book.admin ' ])
160+ ->addEmailRecipient (new EmailRecipient ($ user ->email , $ user ->full_name ))
161+ ->addParams ([
162+ 'user ' => $ user ,
163+ 'create_password_expiration ' => $ config ['password_reset.timeouts.create ' ] / 3600 . ' hours ' ,
164+ 'token ' => $ passwordRequest ->getToken ()
165+ ]);
166+
167+ $ this ->ci ->mailer ->send ($ message );
168+ }
169+
170170 $ ms ->addMessageTranslated ('success ' , 'USER.CREATED ' , $ data );
171171 });
172172
0 commit comments