Cms: setPasswordUrl global twig variable is not working

Created on 3 Dec 2020  路  3Comments  路  Source: craftcms/cms

Description

It looks like the new setPasswordUrl is not working correctly. It doesn't output anything.
Looking through the code I wondered if this was a bug as comparing the lines to the loginUrl and logoutUrl it looks slightly different:

Current Code (lines 1284-1288)

            'isInstalled' => $isInstalled,
            'loginUrl' => UrlHelper::siteUrl($generalConfig->getLoginPath()),
            'logoutUrl' => UrlHelper::siteUrl($generalConfig->getLogoutPath()),
            'setPasswordUrl' => $setPasswordRequestPath !== null ? UrlHelper::siteUrl($setPasswordRequestPath) : null,
            'now' => new DateTime(null, new \DateTimeZone(Craft::$app->getTimeZone()))

Is it missing the $generalConfig-> part?
Should it be:

            'isInstalled' => $isInstalled,
            'loginUrl' => UrlHelper::siteUrl($generalConfig->getLoginPath()),
            'logoutUrl' => UrlHelper::siteUrl($generalConfig->getLogoutPath()),
            'setPasswordUrl' => $setPasswordRequestPath !== null ? UrlHelper::siteUrl($generalConfig->$setPasswordRequestPath) : null,
            'now' => new DateTime(null, new \DateTimeZone(Craft::$app->getTimeZone()))
bug

Most helpful comment

Good spot @olivierbon - this was the exact problem.
I have now updated and can confirm all working as expected.

Thanks @mattstein and @olivierbon 馃憤馃徎

All 3 comments

@terryupton That variable is set further up in the code you referenced.

Can you clarify which Craft version you鈥檙e using and exactly what steps you took (config + template)?

I just tried this with Craft 3.5.16, adding the following to config/general.php...

'setPasswordRequestPath' => '/foo/bar/pass',

...putting {{ setPasswordUrl }} into a .twig template, and having https://test.site/foo/bar/pass rendered in the browser.

If I remove the setPasswordRequestPath line from config/general.php, nothing is rendered in the browser which is the expected behavior.

@terryupton Make sure you are settting setPasswordRequestPath (URI to the _forgot password page_) and not setPasswordPath (URI to the reset form itself - docs)

Good spot @olivierbon - this was the exact problem.
I have now updated and can confirm all working as expected.

Thanks @mattstein and @olivierbon 馃憤馃徎

Was this page helpful?
0 / 5 - 0 ratings

Related issues

richhayler picture richhayler  路  3Comments

bitboxfw picture bitboxfw  路  3Comments

angrybrad picture angrybrad  路  3Comments

timkelty picture timkelty  路  3Comments

benface picture benface  路  3Comments