Skip to content

Commit

Permalink
Always run new users through activateUser()
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Oct 11, 2018
1 parent c6ac3a3 commit db08925
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fixed an error that occurred if a Quick Post widget contained a Matrix field that had Min Blocks set and only had one block type.
- Fixed a bug where the Plugin Store was not working properly with Internet Explorer.
- Fixed a bug where disabled Matrix blocks were getting validated as live. ([#3354](https://github.com/craftcms/cms/issues/3354))
- Fixed a bug where the `EVENT_AFTER_ACTIVATE_USER` event wasn’t getting triggered on user registration when email verification isn’t required. ([craftcms/commerce-digital-products#18](https://github.com/craftcms/commerce-digital-products/issues/18))

### Security
- The `svg()` Twig function no longer sanitizes SVGs or namespaces their IDs or class names by default when a file path (or alias) was passed in. ([#3337](https://github.com/craftcms/cms/issues/3337))
Expand Down
10 changes: 8 additions & 2 deletions src/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,9 @@ public function actionSaveUser()
$user->firstName = $request->getBodyParam('firstName', $user->firstName);
$user->lastName = $request->getBodyParam('lastName', $user->lastName);

// If email verification is required, then new users will be saved in a pending state,
// New users should always be initially saved in a pending state,
// even if an admin is doing this and opted to not send the verification email
if ($isNewUser && $requireEmailVerification) {
if ($isNewUser) {
$user->pending = true;
}

Expand Down Expand Up @@ -1062,6 +1062,12 @@ public function actionSaveUser()
return null;
}

// If this is a new user and email verification isn't required,
// go ahead and activate them now.
if ($isNewUser && !$requireEmailVerification) {
Craft::$app->getUsers()->activateUser($user);
}

// Save their preferences too
$preferences = [
'language' => $request->getBodyParam('preferredLanguage', $user->getPreference('language')),
Expand Down

0 comments on commit db08925

Please # to comment.