ServiceStack/ServiceStack.Contrib — pull request #23 by Aaronaught (2013-06-30 23:12:29+00:00)
Title: Registration with autologin fails when using the RavenUserAuthRepository

RavenDB uses background indexing and allows the use of stale indexes by default, which is great for a lot of things, but security generally isn't one of them.

Specifically, if you try to register with `autoLogin` set (i.e. using the `RegistrationFeature`) while using the RavenDB repository, you end up with an "Invalid UserName or Password" error at the end of it. That is because the service immediately attempts a login after creating the user auth, and when it goes to retrieve the auth document afterward (via `GetUserAuthByUserName`), it's not in the index yet.

Adding `WaitForNonStaleResultsAsOfNow` ensures that any recent user creations/saves are reflected in the query. I've added it to the OAuth queries too, since they are susceptible to similar issues.