<p>I got this working. I refactored my logic to use craft's <code>{{ redirectInput(urlParam) }}</code> instead of writing out my redirect param
that seemed to properly generate the hashed return URL and pass the validation</p>

CC BY-SA 4.0
2024-02-09T17:21:26.233Z
2024-02-09T17:21:26.233Z
justinholtweb
<p>I'm stuck on something and need some advice. I have a frontend login form where I need to dynamically change the redirect input value with JS when it changes. The page has instantsearch in place and I am trying to get the most current URL when a user interacts with the facets. I have a &quot;save your search&quot; setup in place but I have to have the user signed in to do this. I want them to be able to log in with my login form, and then return to the same URL. No matter what I have tried I cannot get Craft to validate the hashed return URL. Currently, I have JS in place that grabs the current URL, encodes it, and passes it as a param to a non-cached route via Ajax that renders a template where I am using the Craft filter <code>|hash</code> on the URL param, and parsing it out, then using that to update the form redirect param. However, it still won't pass validation in Craft and renders a 400 each time.</p>

<url><security><hash>
Redirect url validation failure
# Redirect url validation failure

(Asked by: username_0 on 2024-02-06)

I'm stuck on something and need some advice. I have a frontend login form where I need to dynamically change the redirect input value with JS when it changes. The page has instantsearch in place and I am trying to get the most current URL when a user interacts with the facets. I have a "save your search" setup in place but I have to have the user signed in to do this. I want them to be able to log in with my login form, and then return to the same URL. No matter what I have tried I cannot get Craft to validate the hashed return URL. Currently, I have JS in place that grabs the current URL, encodes it, and passes it as a param to a non-cached route via Ajax that renders a template where I am using the Craft filter `|hash` on the URL param, and parsing it out, then using that to update the form redirect param. However, it still won't pass validation in Craft and renders a 400 each time.

**Tags:** url, security, hash

---

## 1 answers

### Answer by username_0 on 2024-02-09. Score: 1

I got this working. I refactored my logic to use craft's `{{ redirectInput(urlParam) }}` instead of writing out my redirect param
that seemed to properly generate the hashed return URL and pass the validation


---

