Git Product home page Git Product logo

aspnet.identity.ravendb's Introduction

AspNet.Identity.RavenDB

Fully asynchronous, new and sweet ASP.NET Identity implementation for RavenDB.

Getting Started with Version 2.0.0

Using ASP.NET Identity RavenDB port is pretty straight forward. You can install the AspNet.Identity.RavenDB library through NuGet. For now, the AspNet.Identity.RavenDB package which targets the ASP.NET Identity 2.0.0 release is pre-release. So, be sure to use the -pre switch while getting it through NuGet:

Install-Package AspNet.Identity.RavenDB -Pre

The following code snippet shows the easiest way to stand up the UserManager<TUser> class with RavenUserStore<TUser>:

IDocumentStore documentStore = new DocumentStore
{
    Url = "http://localhost:8080",
    DefaultDatabase = "AspNetIdentity"
}.Initialize();

using (IAsyncDocumentSession session = documentStore.OpenAsyncSession())
{
    session.Advanced.UseOptimisticConcurrency = true;
    RavenUserStore<RavenUser> ravenUserStore = new RavenUserStore<RavenUser>(session);
    UserManager<RavenUser> userManager = new UserManager<RavenUser>(ravenUserStore);

    // UserManager<RavenUser> is ready to use!
}

Couple of things to note here:

  • You MUST set the UseOptimisticConcurrency flag to true on the IAsyncDocumentSession as shown above and leave it enabled till the end of the IAsyncDocumentSession lifetime because we need to ensure the uniqueness of the username and the email. RavenUserStore<TUser> checks if you enabled optimistic concurrency or not on its constructor. If you didn't, it will throw an exception. However, optimistic concurrency can be disabled any time during the IAsyncDocumentSession lifetime by the session provider. That's why the library cannot possibly be sure to warn 100% of the time. So, it is extremely important to obey this rule and leave the optimistic concurrency enabled on the session till the end of its lifetime. Otherwise, you will have a chance of ending up overriding an existing user's data if a new user tries to register with the username of that existing user (which would be chaotic for you)!

  • You don't need to use RavenUser entity type. However, your custom entity class must be derived from RavenUser class.

Resources for Version 1.0.0

aspnet.identity.ravendb's People

Contributors

tugberkugurlu avatar thoemmi avatar

Watchers

James Cloos avatar Fernando Nogueira avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.