Skip to content

Commit

Permalink
Link to the front end's Set Password template when sent from the fron…
Browse files Browse the repository at this point in the history
…t end

Resolves #16340
  • Loading branch information
brandonkelly committed Dec 23, 2024
1 parent 0da8725 commit 350d39f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
- The system Login template is now rendered from `/login` (per the `loginPath` config setting) if a site template doesn’t exist in the same location. ([#16344](https://github.com/craftcms/cms/pull/16344))
- When a user with an active two-step verification method logs in from the front end, they’ll be redirected to `/login` (per the `loginPath` config setting) to complete the verification process. ([#16344](https://github.com/craftcms/cms/pull/16344))
- System templates (Login, Set Password, and error message screens) now have more generic styling when rendered on the front end, and can now have custom CSS styling via the `systemTemplateCss` config setting. ([#16344](https://github.com/craftcms/cms/pull/16344))
- Verification emails now link to the front-end Set Password form, if the email was sent from the front end. ([#16340](https://github.com/craftcms/cms/issues/16340))
- Database rows with foreign keys referencing nonexistent rows are now deleted via garbage collection.
- Pages which contain image transform generation URLs now set no-cache headers. ([#16195](https://github.com/craftcms/cms/discussions/16195))
- Reduced the size of GraphQL introspection schemas. ([#16326](https://github.com/craftcms/cms/pull/16326))
Expand Down
7 changes: 5 additions & 2 deletions src/services/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,12 @@ private function _getUserUrl(User $user, string $fePath, string $cpPath): string
'id' => $user->uid,
];

$isCpRequest = Craft::$app->getRequest()->getIsCpRequest();
$generalConfig = Craft::$app->getConfig()->getGeneral();

$cp = (
$user->can('accessCp') ||
Craft::$app->edition->value < CmsEdition::Pro->value ||
($isCpRequest && $user->can('accessCp')) ||
($generalConfig->headlessMode && !UrlHelper::isAbsoluteUrl($fePath))
);
$scheme = UrlHelper::getSchemeForTokenizedUrl($cp);
Expand All @@ -1610,7 +1613,7 @@ private function _getUserUrl(User $user, string $fePath, string $cpPath): string

// Only use cpUrl() if this is a control panel request, or the base control panel URL has been explicitly set,
// so UrlHelper won't use HTTP_HOST
if ($generalConfig->baseCpUrl || Craft::$app->getRequest()->getIsCpRequest()) {
if ($generalConfig->baseCpUrl || $isCpRequest) {
$url = UrlHelper::cpUrl($cpPath, $params, $scheme);
} else {
$path = UrlHelper::prependCpTrigger($cpPath);
Expand Down

0 comments on commit 350d39f

Please sign in to comment.