title: Using if-guard in for-comprehension to check for existence
body: <p>My am making 3 database queries, each return a <code>Future</code>. I am trying to use <code>for</code> comprehension to resolve the <code>Future</code>s but it seems I am not using <code>if</code> correctly in <code>for</code></p>
  
  <p>Each query depends on result of previous one. I look for a <code>token</code>, if found, I look for <code>user</code> and it found, I update the <code>user</code>. Each database query returns a <code>Future[Option]]</code> and I thought I could considitionally perform the next query depending on whether the previous one returns <code>Some</code> or <code>None</code>. I am using <code>isDefined</code> for this. But when I ran the code for an invalid token, I got error <code>[NoSuchElementException: None.get]</code> for code <code>userOption:Option[User]&lt;-userRepo.findUser(tokenOption.get.loginInfo); if tokenOption.isDefined</code></p>
  
  <pre><code>def verifyUser(token:String) = Action.async {
    implicit request =&gt; {
      val result:Future[Result] = for{
        //generator 1 - get token from database
        tokenOption:Option[UserToken] &lt;- userTokenRepo.find(UserTokenKey(UUID.fromString(token)))
        //generator2. found token, look for corresponding user to which the token belongs
        userOption:Option[User] &lt;- userRepo.findUser(tokenOption.get.loginInfo); if tokenOption.isDefined
        //generator 3. found user and token. Update profile 
        modifiedUser:Option[User] &lt;-  confirmSignupforUser(userOption.get); if userOption.isDefined
         } yield 
           { //check if we have user and token and modified user here. If any is missing, return error else success
             if(tokenOption.isDefined &amp;&amp; userOption.isDefined &amp;&amp; modifiedUser.isDefined)
                Redirect("http://localhost:9000/home"+";signup=success")//TODOM - pick from config
             else
               if(tokenOption.isEmpty)
               Redirect("http://localhost:9000/home"+";signup=error")//TODOM - pick from config
             else if(userOption.isEmpty)
               Redirect("http://localhost:9000/home"+";signup=error")//TODOM - pick from config
             else if(modifiedUser.isEmpty)
               Redirect("http://localhost:9000/home"+";signup=error")//TODOM - pick from config
             else //this shouldn't happen. Unexpected
               Redirect("http://localhost:9000/home"+";signup=error")//TODOM - pick from config
           }
         result
       }
     }
  </code></pre>