<p>The way I handle this is by simply <code>include</code>ing the same template as the login page and passing a Twig variable along with it.</p>
<p>So more specifically, my <code>setPasswordSuccessPath</code> is set to a unique template called <code>password-was-reset</code>, which has the following code in it and nothing else:</p>
<p><code>{% include 'login' with { passwordWasReset: true } %}</code></p>
<p>You can then read that variable in your login template like this - as you can see I'm also doing the same thing with my account activation template:</p>
<pre><code>    {% if passwordWasReset is defined and passwordWasReset and errorMessage is not defined %}       
        &lt;p&gt;Your password was reset successfully. Please log in below.&lt;/p&gt;       
    {% endif %}

    {% if accountWasActivated is defined and accountWasActivated and errorMessage is not defined %}
        &lt;p&gt;Your account was activated successfully. Please log in below.&lt;/p&gt;
    {% endif %}

    ...

    &lt;login form here&gt;
</code></pre>

CC BY-SA 4.0
2024-09-25T14:31:06.757Z
I opted for a redirect instead of include `{% redirect 'login' with notice "password_was_set" %}`. Thanks for the hint. https://craftcms.com/docs/5.x/reference/twig/tags.html#flash-messages
Masiorama
CC BY-SA 4.0
2020-08-24T11:03:42.417Z
2024-09-25T15:29:37.490Z
2024-09-25T15:29:37.490Z
James Smith
<p>Quick question about password reset (forgot a password on the front-end)</p>
<p>So I have set my<br />
<code>'setPasswordSuccessPath'           =&gt; 'login'</code><br />
so that when the new password is set, they will be taken to this login screen.</p>
<p>Is there anyway i can detect this has come from this process, so I can show a little flash message to confirm their password has been reset? I'd like to give some visual feedback, without a whole separate interim page.</p>

<form><password>
Forgot Password - Success Message/Flash Message after setting new password on the login screen
# Forgot Password - Success Message/Flash Message after setting new password on the login screen

(Asked by: username_0 on 2020-08-24)

Quick question about password reset (forgot a password on the front-end)

So I have set my  
`'setPasswordSuccessPath' => 'login'`  
so that when the new password is set, they will be taken to this login screen.

Is there anyway i can detect this has come from this process, so I can show a little flash message to confirm their password has been reset? I'd like to give some visual feedback, without a whole separate interim page.

**Tags:** form, password


---

## 1 answers

### Answer by username_1 on 2020-08-24. Score: 2

The way I handle this is by simply includeing the same template as the login page and passing a Twig variable along with it.
So more specifically, my setPasswordSuccessPath is set to a unique template called password-was-reset, which has the following code in it and nothing else:
{% include 'login' with { passwordWasReset: true } %}
You can then read that variable in your login template like this - as you can see I'm also doing the same thing with my account activation template:
    {% if passwordWasReset is defined and passwordWasReset and errorMessage is not defined %}       
        Your password was reset successfully. Please log in below.       
    {% endif %}

    {% if accountWasActivated is defined and accountWasActivated and errorMessage is not defined %}
        Your account was activated successfully. Please log in below.
    {% endif %}

    ...

> **Comments:**
> **username_2**: I opted for a redirect instead of include `{% redirect 'login' with notice "password_was_set" %}`. Thanks for the hint. https://craftcms.com/docs/5.x/reference/twig/tags.html#flash-messages  

---

