Closed WilliamDoman closed 10 years ago
Here is my UserManager which is creating a user within RavenDB. FYI ApplicationUser is inheriting from RavenUser.
public class ApplicationUserManager : UserManager
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var session = context.Get<IAsyncDocumentSession>();
session.Advanced.UseOptimisticConcurrency = true;
var manager = new ApplicationUserManager(new RavenUserStore<ApplicationUser>(session));
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
manager.UserLockoutEnabledByDefault = true;
manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5);
manager.MaxFailedAccessAttemptsBeforeLockout = 5;
manager.EmailService = new EmailService();
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 8,
RequireNonLetterOrDigit = true,
RequireDigit = true,
RequireLowercase = false,
RequireUppercase = false,
};
var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null)
{
manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
}
return manager;
}
This is within the startup.Auth
app.CreatePerOwinContext
@jakvike Thanks! What does your ApplicationSession.Create look like? I'm a raven noobie.
public class ApplicationSession : IDisposable { public static IAsyncDocumentSession Create() { return MvcApplication.Store.OpenAsyncSession(); }
public void Dispose()
{
MvcApplication.Store.Dispose();
}
}
Global.asax
public class MvcApplication : System.Web.HttpApplication { public static IDocumentStore Store;
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
Store = new DocumentStore { ConnectionStringName = "RavenDB" };
Store.Initialize();
IndexCreation.CreateIndexes(Assembly.GetCallingAssembly(), Store);
}
}
You and I both are Noobs!
@jakvike
Thanks! that was a big big big help
You are welcome!
Thank you,
Jake Kapp
On Thu, Apr 24, 2014 at 3:50 PM, William Doman notifications@github.comwrote:
@jakvike https://github.com/jakvike
Thanks! that was a big big big help
— Reply to this email directly or view it on GitHubhttps://github.com/tugberkugurlu/AspNet.Identity.RavenDB/issues/30#issuecomment-41330364 .
Has anybody got this working in the OWIN pipeline?
I'm trying to mimic the EF implementation, per owin request. Unless theres a better way...
Where AppUserManager : UserManager
and