1 using System.Threading.Tasks;
2 using Microsoft.AspNet.Identity;
3 using Microsoft.AspNet.Identity.EntityFramework;
4 using Microsoft.AspNet.Identity.Owin;
6 using CPE.App.Api.Models;
10 // Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application.
12 public class ApplicationUserManager : UserManager<ApplicationUser>
14 public ApplicationUserManager(IUserStore<ApplicationUser> store)
19 public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
21 var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
22 // Configure validation logic for usernames
23 manager.UserValidator = new UserValidator<ApplicationUser>(manager)
25 AllowOnlyAlphanumericUserNames = false,
26 RequireUniqueEmail = true
28 // Configure validation logic for passwords
29 manager.PasswordValidator = new PasswordValidator
32 RequireNonLetterOrDigit = true,
34 RequireLowercase = true,
35 RequireUppercase = true,
37 var dataProtectionProvider = options.DataProtectionProvider;
38 if (dataProtectionProvider != null)
40 manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));