Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-25T14:31:06.757Z
Answers.Text: 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
Answers.UserDisplayName: Masiorama
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-24T11:03:42.417Z
Answers.LastActivityDate: 2024-09-25T15:29:37.490Z
Answers.LastEditDate: 2024-09-25T15:29:37.490Z
Answers.UserDisplayName: James Smith
Body: <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>
  
Tags: <form><password>
Title: Forgot Password - Success Message/Flash Message after setting new password on the login screen
ThreadText: # 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 `include`ing 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 %}       
          <p>Your password was reset successfully. Please log in below.</p>       
      {% endif %}
  
      {% if accountWasActivated is defined and accountWasActivated and errorMessage is not defined %}
          <p>Your account was activated successfully. Please log in below.</p>
      {% endif %}
  
      ...
  
      <login form here>
  
  ```
  
  > **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  
  
  ---
  
  