Skip to content

Commit

Permalink
Fixed #4025
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Mar 21, 2019
1 parent 9f9e3cf commit c7e3ea3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Fixed a bug where Craft wasn’t respecting the site selection for routes defined in Settings → Routes. ([#4021](https://github.com/craftcms/cms/issues/4021))
- Fixed an error where exception would not be logged if encountering an error while applying project config changes using the `project-config/sync` console command ([#4015](https://github.com/craftcms/cms/issues/4015))
- Fixed a bug where field UIDs could get overwritten in some scenarios.
- Fixed an error that occurred when attempting to use Live Preview with a pending user account. ([#4025](https://github.com/craftcms/cms/issues/4025))

## 3.1.19 - 2019-03-19

Expand Down
7 changes: 6 additions & 1 deletion src/controllers/LivePreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ public function actionPreview(string $previewAction, int $userId)
$this->requireToken();

// Switch the identity for this one request
$user = User::findOne($userId);
$user = User::find()
->id($userId)
->status([User::STATUS_ACTIVE, User::STATUS_PENDING])
->one();

if (!$user) {
throw new ServerErrorHttpException('No user exists with an ID of ' . $userId);
}

Craft::$app->getUser()->setIdentity($user);

// Add CORS headers
Expand Down

0 comments on commit c7e3ea3

Please sign in to comment.