当前位置: 首页>>代码示例>>C#>>正文


C# ApplicationUserManager类代码示例

本文整理汇总了C#中ApplicationUserManager的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUserManager类的具体用法?C# ApplicationUserManager怎么用?C# ApplicationUserManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationUserManager类属于命名空间,在下文中一共展示了ApplicationUserManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StatisticsController

 public StatisticsController()
 {
     db = new ApplicationDbContext();
     userStore = new UserStore<ApplicationUser>(db);
     userManager = new ApplicationUserManager(userStore);
     statisticsService = new StatisticsService(db);
 }
开发者ID:yuraokilka,项目名称:GymDiary,代码行数:7,代码来源:StatisticsController.cs

示例2: ManageUsersController

 public ManageUsersController(ApplicationDbContext context, ApplicationUserManager userManager, IEmailService emailService, ICurrentUser currentUser)
 {
     _context = context;
     _userManager = userManager;
     _emailService = emailService;
     _currentUser = currentUser;
 }
开发者ID:rswetnam,项目名称:GoodBoating,代码行数:7,代码来源:ManageUsersController.cs

示例3: AccountController

 public AccountController(
     ApplicationUserManager userManager,
     ApplicationSignInManager signInManager)
 {
     this.UserManager = userManager;
     this.SignInManager = signInManager;
 }
开发者ID:ASP-MVC,项目名称:Snippy,代码行数:7,代码来源:AccountController.cs

示例4: GetClaims

        public async static Task<IEnumerable<Claim>> GetClaims(ClaimsIdentity user)
        {
            List<Claim> claims = new List<Claim>();
            using (edisDbEntities db = new edisDbEntities())
            {
                if (user.HasClaim(c => c.Type == ClaimTypes.Role && c.Value == AuthorizationRoles.Role_Client))
                {

                    var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    var userProfile = await userManager.FindByNameAsync(user.Name);

                    var client = db.Clients.FirstOrDefault(c => c.ClientUserID == userProfile.Id);
                    if (client != null)
                    {
                        var clientGroup = db.ClientGroups.FirstOrDefault(c => c.ClientGroupID == client.ClientGroupID);
                        if (clientGroup != null && clientGroup.MainClientID == client.ClientUserID)
                        {
                            claims.Add(CreateClaim(ClaimType_ClientGroupLeader, ClaimValue_ClientGroupLeader_Leader));
                        }
                        else
                        {
                            claims.Add(CreateClaim(ClaimType_ClientGroupLeader, ClaimValue_ClientGroupLeader_Member));
                        }
                    }
                }
            }
            return claims;
        }
开发者ID:stevenzhenhaowang,项目名称:EDISAngular,代码行数:28,代码来源:ClientGroupLeaderClaimProvider.cs

示例5: RegenerateIdentityCallback

 /// <summary>
 /// Regenerates the identity callback function for cookie configuration (above).
 /// </summary>
 /// <param name="applicationUserManager">The application user manager.</param>
 /// <param name="applicationUser">The application user.</param>
 private static async Task<ClaimsIdentity> RegenerateIdentityCallback(ApplicationUserManager applicationUserManager, ApplicationUser applicationUser)
 {
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
     var userIdentity = await applicationUserManager.CreateIdentityAsync(applicationUser, DefaultAuthenticationTypes.ApplicationCookie);
     // Add custom user claims here
     return userIdentity;
 }
开发者ID:targitaj,项目名称:m3utonetpaleyerxml,代码行数:12,代码来源:AuthenticationHelper.cs

示例6: AddUserToRole

 public bool AddUserToRole(string userId, string roleName)
 {
     var um = new ApplicationUserManager(
         new UserStore<ApplicationUser>(context));
     var idResult = um.AddToRole(userId, roleName);
     return idResult.Succeeded;
 }
开发者ID:BenVandenberk,项目名称:EindwerkNET,代码行数:7,代码来源:IdentityModels.cs

示例7: Application_Start

        protected async void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // ユーザーとロールの初期化
            // ロールの作成
            var roleManager = new ApplicationRoleManager(new UserStore());
            await roleManager.CreateAsync(new ApplicationRole { Name = "admin" });
            await roleManager.CreateAsync(new ApplicationRole { Name = "users" });

            var userManager = new ApplicationUserManager(new UserStore());
            // 一般ユーザーの作成
            await userManager.CreateAsync(new ApplicationUser { UserName = "tanaka" }, "[email protected]");
            await userManager.AddToRoleAsync(
                (await userManager.FindByNameAsync("tanaka")).Id,
                "users");
            // 管理者の作成
            await userManager.CreateAsync(new ApplicationUser { UserName = "super_tanaka" }, "[email protected]");
            await userManager.AddToRoleAsync(
                (await userManager.FindByNameAsync("super_tanaka")).Id,
                "users");
            await userManager.AddToRoleAsync(
                (await userManager.FindByNameAsync("super_tanaka")).Id,
                "admin");

            Debug.WriteLine("-----------");
        }
开发者ID:runceel,项目名称:ASPNETIdentity,代码行数:28,代码来源:Global.asax.cs

示例8: AccountController

 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
 {
     sendMail = new SendMail();
     UserManager = userManager;
     SignInManager = signInManager;
     usService = new UserService();
 }
开发者ID:devnarayan,项目名称:LiraTaxiApi,代码行数:7,代码来源:AccountController.cs

示例9: IdentityModelHelper

 public IdentityModelHelper(ApplicationUserManager userManager, ApplicationRoleManager roleManager)
 {
     Contract.Assert(null != userManager);
     Contract.Assert(null != roleManager);
     _userManager = userManager;
     _roleManager = roleManager;
 }
开发者ID:PF2000,项目名称:AppLabRedes,代码行数:7,代码来源:IdentityModelHelper.cs

示例10: AccountController

 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager,
     ApplicationRoleManager roleManager)
 {
     UserManager = userManager;
     SignInManager = signInManager;
     RoleManager = roleManager;
 }
开发者ID:sthapa123,项目名称:PV247-Expense-manager,代码行数:7,代码来源:AccountController.cs

示例11: ManageController

 public ManageController(ApplicationSignInManager signinManager, ApplicationUserManager appUserManager, IAuthenticationManager authenticationManager)
     : base(appUserManager)
 {
     AuthenticationManager = authenticationManager;
     UserManager = appUserManager;
     SignInManager = signinManager;
 }
开发者ID:EhrgoHealth,项目名称:CS6440,代码行数:7,代码来源:ManageController.cs

示例12: AccountController

        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, LmsUserManager lmsUserManager)
        {
            UserManager = userManager;
            SignInManager = signInManager;
            _lmsUserManager = lmsUserManager;

        }
开发者ID:jmullins1992,项目名称:Portfolio,代码行数:7,代码来源:AccountController.cs

示例13: CreateAccount

        public ActionResult CreateAccount(NewUserModel model)
        {
            if (ModelState.IsValid)
            {
                ApplicationUserManager um = new ApplicationUserManager(new ApplicationUserStore(new ApplicationDbContext()));
                var pass = StringHelper.RandomString(8, 10);
                var user = new ApplicationUser()
                {
                    Id = Guid.NewGuid().ToString(),
                    UserName = model.UserName,
                    Email = model.Email,
                    Created = DateTime.Now,
                    LastLogin = null
                };
                var result = um.Create(user, pass);
                if(result.Succeeded)
                {
                    MailHelper.WelcomeSendPassword(user.UserName, user.Email, pass);
                    return RedirectToAction("Index", "People");
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }
            }

            return View(model);
        }
开发者ID:hurtonypeter,项目名称:onlab,代码行数:31,代码来源:PeopleController.cs

示例14: IdentityUnitOfWork

 public IdentityUnitOfWork(string connectionString)
 {
     db = new StoreContext(connectionString);
     UserManager = new ApplicationUserManager(new UserStore<ApplicationUser>(db));
     RoleManager = new ApplicationRoleManager(new RoleStore<ApplicationRole>(db));
     ClientManager = new ClientManager(db);
 }
开发者ID:belush,项目名称:Store,代码行数:7,代码来源:IdentityUnitOfWork.cs

示例15: TestWeekMenuController

 public TestWeekMenuController()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _db = _unitOfWork.GetContext();
     _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
     _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
 }
开发者ID:densem-2013,项目名称:ACSDining,代码行数:7,代码来源:TestWeekMenuController.cs


注:本文中的ApplicationUserManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。