Skip to content

Commit

Permalink
Activate users from users/create
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed May 14, 2022
1 parent 8888bfa commit f45c185
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Added
- The `AdminTable` Vue component can now be included into other Vue apps, in addition to being used as a standalone app. ([#11107](https://github.com/craftcms/cms/pull/11107))
- Added a `one()` alias for `first()` to collections. ([#11134](https://github.com/craftcms/cms/discussions/11134))
- Added `craft\console\controllers\UsersController::$activate`.
- Added `craft\elements\conditions\ElementCondition::$sourceKey`.

### Changed
Expand All @@ -14,6 +15,7 @@
- Sites’ Language settings now display the locale IDs as option hints, rather than the languages’ native names. ([#11195](https://github.com/craftcms/cms/discussions/11195))
- Selectize options can now specify searchable `keywords` that won’t be visible in the UI.
- Selectize inputs will now include their options’ values as search keywords.
- The `users/create` command now asks whether the user should be activated when saved.

### Removed
- Removed `craft\elements\conditions\entries\EntryTypeCondition::$sectionUid`.
Expand Down
8 changes: 8 additions & 0 deletions src/console/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class UsersController extends Controller
*/
public ?bool $admin = null;

/**
* @var bool|null Whether teh user account should be activated.
* @since 4.1.0
*/
public ?bool $activate = null;

/**
* @var string[] The group handles to assign the created user to.
* @since 3.7.0
Expand Down Expand Up @@ -203,6 +209,8 @@ public function actionCreate(): int
}
}

$user->active = $this->activate ?? $this->confirm('Activate the account?', $user->newPassword !== null);

$this->stdout('Saving the user ... ');

if (!Craft::$app->getElements()->saveElement($user)) {
Expand Down

0 comments on commit f45c185

Please sign in to comment.