title: Play/Scala: use Redirect in ActionBuilder
body: <p>I'm trying to build a simple action to use in Play controller to check if the session is active:</p>
  
  <pre><code>import play.api.mvc._
  import scala.concurrent._
  
  object AuthAction extends ActionBuilder[Request] {
  
      def invokeBlock[A](request: Request[A], block: (Request[A]) =&gt; Future[SimpleResult]) = {
          if (request.session.isEmpty) {
              //Need to redirect to login page    
              Redirect("/login")
          } else {
              //Session is found, continue Action as normal
              block(request)
          }
      }
  
  }
  </code></pre>
  
  <p>Problem is, it doesn't recognize <code>Redirect</code>. How do I get it to work in this scope? I want to use this action in my controllers where authorisation is required:</p>
  
  <pre><code>object Application extends Controller {
  
      def index = AuthAction {
          Ok(views.html.index("You are logged in."))
      }
  
  }
  </code></pre>
  
  <p>These two would be different files.</p>
  
  <p>Side question: what exactly is "A" in <code>invokeBlock[A]</code> and <code>Request[A]</code>?</p>
  
  <p>I'm on Play 2.2.1, Scala 2.10.3, Java 1.8 64bit</p>
  
  <p><strong>UPDATE:</strong> Tried this, it doesn't give any errors any more, but it doesn't work - Redirect seems to be ignored.</p>
  
  <pre><code>import play.api.mvc._
  import scala.concurrent._
  import play.api.mvc.Results._
  
  object AuthAction extends ActionBuilder[Request] {
  
      def invokeBlock[A](request: Request[A], block: (Request[A]) =&gt; Future[SimpleResult]) = {
          if (request.session.isEmpty) {
              Redirect("/login")
          }
          block(request)
      }
  
  }
  </code></pre>