예제 #1
0
        public static MyUserManager Create(IdentityFactoryOptions <MyUserManager> options, IOwinContext context)
        {
            var manager =
                new MyUserManager(
                    new UserStore <MyUser, MyRole, int, MyLogin, MyUserRole, MyClaim>(
                        context.Get <ApplicationDbContext>()));

            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <MyUser, int>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator()
            {
                RequireDigit            = false,
                RequireLowercase        = false,
                RequireNonLetterOrDigit = false,
                RequireUppercase        = false,
                RequiredLength          = 0
            };

            return(manager);
        }
예제 #2
0
        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(MyUserManager userManager)
        {
            var userIdentity = await userManager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

            // Add custom user claims here
            return(userIdentity);
        }
예제 #3
0
        public static MyUserManager Initialize()
        {
            var manager =
                new MyUserManager(
                    new UserStore <MyUser, MyRole, int, MyLogin, MyUserRole, MyClaim>(new ApplicationDbContext()));

            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <MyUser, int>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit            = true,
                RequireLowercase        = true,
                RequireUppercase        = true,
            };

            return(manager);
        }