Added RavenUserAuthRepository for RavenDB authentication support#18
Added RavenUserAuthRepository for RavenDB authentication support#18mythz merged 1 commit intoServiceStackV3:masterfrom
Conversation
Added RavenUserAuthRepository for RavenDB authentication support
|
Brilliant, thx! |
|
Why does he register this auth provider against MvcApplication.Store? What is MvcApplication.Store in his case? Why does the constructor want IDocumentStore instance, when most registratitions are done with IDocumentSession? I have EmbeddableDocumentStore registered as IDocumentSession: Autofac: ? |
|
Store is the DocumentStore object that is created once per application (http://ravendb.net/kb/3/using-ravendb-in-an-asp-net-mvc-website). Are you running into problems? |
|
As described in the article you are referring to, we should use IDocumentSession interface in controllers and as such we register the IDocumentSession with IoC container not the IDocumentStore. Like this: So the contructor in RavenUserAuthRepository should accept IDocumentSession or at least two constructors should exists, one with IDocumentStore and another with IDocumentSession. I also don't like how you are opening the session yourself in the repository. If you'd use IDocumentSession provided by the container the container would manage opening, closing and initializing the session. Will you change it or should I implement my own solution? |
|
The point is, having MvcApplication.Store as a global object doesn't make much sense, especially when you have a DI container serving the registered service implementations.. |
|
Good point, the example is pretty lousy as it uses ioc for the provider but not for raven session. As for opening a session inside it... I don't think it matters too much as no db objects travel in or out f the provider. but I agree that it would make sense to use session directly if its already managed by something. Feel free to make changes as I wont have time for few weeks at this point :\ |
|
I found out an alternative to access the document store from the registered Session. Hopefully this will work (haven't tried it out yet): |
Usage in an MVC environment: