title: In Play! 2.0 with Security trait how do I redirect to the original URL after login?
body: <p>With Play! framework 2.0, using the <a href="https://github.com/playframework/Play20/wiki/ScalaSecurity" rel="nofollow noreferrer">Security Trait</a>:</p>
  
  <p>If I let users browse to several parts of the site unauthenticated, but on certain actions they need to authenticate, how do I redirect them to their original url before authentication and not the same url for all?</p>
  
  <p>It is a similar requirement to this question for Play! 1.x <a href="https://stackoverflow.com/questions/7469312/playframeworks-secure-module-is-not-redirecting-to-the-original-url-after-login">Playframework&#39;s Secure module is not redirecting to the original url after login</a>.</p>
  
  <p>However the flash parameter for the original url is not available in 2.0 as far as I can tell.</p>
  
  <p>Basicaly the change I am looking for would be in the <strong>authenticate</strong> method handler</p>
  
  <pre><code>def authenticate = Action { implicit request =&gt;
      loginForm.bindFromRequest.fold(
        formWithErrors =&gt; BadRequest(html.login(formWithErrors)),
        user =&gt; Redirect(routes.Application.index).withSession(Security.username -&gt; user._1)
      )
    }
  </code></pre>
  
  <p>Where some sort of <strong>Redirect(originalRequestUrl)</strong> would be handy.</p>
  
  <p>Any ideas for a clean solution?</p>