Ejemplo n.º 1
0
        public static InisraUserManager Create(IdentityFactoryOptions <InisraUserManager> options, IOwinContext context)
        {
            var manager = new InisraUserManager(new UserStore <InisraUser>(context.Get <InisraContext>()));

            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <InisraUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                //RequireNonLetterOrDigit = true,
                RequireDigit = true,
                //RequireLowercase = true,
                //RequireUppercase = true,
            };

            // Configure user lockout defaults
            manager.UserLockoutEnabledByDefault          = true;
            manager.DefaultAccountLockoutTimeSpan        = TimeSpan.FromMinutes(5);
            manager.MaxFailedAccessAttemptsBeforeLockout = 5;

            // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user
            // You can write your own provider and plug it in here.
            manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider <InisraUser>
            {
                MessageFormat = "Your security code is {0}"
            });
            manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider <InisraUser>
            {
                Subject    = "Security Code",
                BodyFormat = "Your security code is {0}"
            });
            manager.EmailService = new EmailService();
            manager.SmsService   = new SmsService();
            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider =
                    new DataProtectorTokenProvider <InisraUser>(dataProtectionProvider.Create("ASP.NET Identity"));
            }
            return(manager);
        }
Ejemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            var context        = new InisraContext();
            var IdentityResult = new IdentityResult();

            var InisraRoleManager = new RoleManager <IdentityRole>
                                        (new RoleStore <IdentityRole>(context));

            if (!InisraRoleManager.RoleExists("Admin"))
            {
                IdentityResult = InisraRoleManager.Create(new IdentityRole("Admin"));
            }

            if (!InisraRoleManager.RoleExists("JobSeeker"))
            {
                InisraRoleManager.Create(new IdentityRole("JobSeeker"));
            }

            if (!InisraRoleManager.RoleExists("Company"))
            {
                InisraRoleManager.Create(new IdentityRole("Company"));
            }

            var InisraUserManager = new InisraUserManager(new UserStore <InisraUser>(context));
            var Admin             = new Administrator {
                FirstName = "Ferid",
                LastName  = "Zuber",
                UserName  = "******",
                Email     = "*****@*****.**"
            };

            var Result = InisraUserManager.Create(Admin, "Admin@123");

            if (InisraRoleManager.RoleExists("Admin") && Result.Succeeded)
            {
                InisraUserManager.AddToRole(InisraUserManager.FindByName("Ferido07").Id, "Admin");
            }

            AutoMapperConfig.Configure();
            Inisra.Solr.Startup.Init();
        }
Ejemplo n.º 3
0
 public ApplicationSignInManager(InisraUserManager userManager, IAuthenticationManager authenticationManager)
     : base(userManager, authenticationManager)
 {
 }