コード例 #1
0
 public ApplicationSignInManager(AppUserManager userManager, IAuthenticationManager authenticationManager)
     : base(userManager, authenticationManager)
 {
 }
コード例 #2
0
        public void PerformInitialSetup(AppIdentityDbContext context)
        {
            // initial configuration will go here
            // 初始化配置将放在这儿 eg:初始化数据
            AppRoleManager roleMgr = new AppRoleManager(new RoleStore <AppRole>(context));
            AppUserManager userMgr = new AppUserManager(new UserStore <AppUser>(context));
            AppRole        role00  = new AppRole {
                Id = "R00", Name = "Governor"
            };
            AppRole role01 = new AppRole {
                Id = "R01", Name = "Admin"
            };
            AppRole role02 = new AppRole {
                Id = "R02", Name = "Manager"
            };
            AppRole role03 = new AppRole {
                Id = "R03", Name = "Employee"
            };

            if (!roleMgr.RoleExists("Governor"))
            {
                roleMgr.Create(role00);
            }
            if (!roleMgr.RoleExists("Admin"))
            {
                roleMgr.Create(role01);
            }
            if (!roleMgr.RoleExists("Manager"))
            {
                roleMgr.Create(role02);
            }
            if (!roleMgr.RoleExists("Employee"))
            {
                roleMgr.Create(role03);
            }

            Company company = new Company
            {
                CompanyName    = "LivellPayroll",
                TimeZone       = "0",
                Email          = "*****@*****.**",
                PayFreq        = "Weekly",
                RoundTo        = "15",
                PayRollRegTime = DateTime.Now
            };
            AppUser GovernorUser = new AppUser
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                PayRollUser    = "******",
                TimeZone       = "0",
                LastLoginDate  = DateTime.UtcNow,
                Company        = company
            };
            var user = userMgr.FindByEmail("*****@*****.**");

            if (user == null)
            {
                var result = userMgr.Create(GovernorUser, "Governor123456");
                if (result.Succeeded)
                {
                    userMgr.AddToRole(GovernorUser.Id, "Governor");
                }
            }
            ;
            Initialize_DmTimeZone(context);
        }