• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ApplicationUserManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AccountController

 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ILogAppService logAppService, IPrestadorAppService prestadorAppService)
 {
     _userManager = userManager;
     _signInManager = signInManager;
     _logAppService = logAppService;
     _prestadorAppService = prestadorAppService;
 }
开发者ID:caiocardozocb3,项目名称:Gestao,代码行数:7,代码来源:AccountController.cs


示例17: CreateUser

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


示例18: GenerateUserIdentity

 public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
 {
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
     var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
     // Add custom user claims here
     return userIdentity;
 }
开发者ID:Varbanov,项目名称:TelerikAcademy,代码行数:7,代码来源:AppUser.cs


示例19: TestRegister

        public void TestRegister()
        {
            //http://blogs.interknowlogy.com/2014/08/21/mvc-series-part-2-accountcontroller-testing/
            Mock<IEmailer> EmailerMock = new Mock<IEmailer>();
            Mock<IUserStore<ApplicationUser>> userStoreMock = new Mock<IUserStore<ApplicationUser>>();
            ApplicationUserManager userManager = new ApplicationUserManager(userStoreMock.Object);
            //IAuthenticationManager authManager = AuthenticationManager.
            Mock< IAuthenticationManager> authMock = new Mock<IAuthenticationManager>();
            ApplicationSignInManager manager = new ApplicationSignInManager(userManager, authMock.Object);

            AccountController Controller = new AccountController(userManager, manager, EmailerMock.Object);
            Mock<AccountController> ControllerMock = new Mock<AccountController>(EmailerMock.Object);

            Mock<ApplicationUserManager> UserManagerMock = new Mock<ApplicationUserManager>();
            Mock<ApplicationSignInManager> AppSignInManagerMock = new Mock<ApplicationSignInManager>();

            RegisterViewModel vm = new RegisterViewModel()
            {
                UserName    = "Test",
                Email = "[email protected]",

                UserRole = "Teacher"
            };

            var result = Controller.Register(vm).Result;

            EmailerMock.Verify(a => a.Send());
        }
开发者ID:hbdal,项目名称:curri,代码行数:28,代码来源:TestAccountController.cs


示例20: ConfigureOAuth

        public void ConfigureOAuth(IAppBuilder app, HttpConfiguration config)
        {
            UserManagerFactory = () =>
            {
                try
                {
                    var userRepository = config.DependencyResolver.GetService(typeof(IUserRepository));
                    var userManager =
                        new ApplicationUserManager(userRepository as IUserRepository);
                    return userManager;
                }
                catch (Exception)
                {
                    return null;
                }
            };

            app.CreatePerOwinContext(UserManagerFactory);

            var oAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                Provider = new SimpleAuthorizationProvider()
            };

            app.UseOAuthAuthorizationServer(oAuthServerOptions);

            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
开发者ID:jonahtaxt,项目名称:Effisoft.RookieBetting,代码行数:31,代码来源:Startup.Auth.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ApplicationViewState类代码示例发布时间:2022-05-24
下一篇:
C# ApplicationUser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap