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


C# IUserManager.CreateUser方法代码示例

本文整理汇总了C#中IUserManager.CreateUser方法的典型用法代码示例。如果您正苦于以下问题:C# IUserManager.CreateUser方法的具体用法?C# IUserManager.CreateUser怎么用?C# IUserManager.CreateUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUserManager的用法示例。


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

示例1: AuthModule

        public AuthModule(ILogger<AuthModule> logger,
            IUserManager userManager,
            ITokenizer tokenizer)
            : base("auth")
        {
            Get["/setup"] = _ => !userManager.HasUsers();

            Post["/login"] = _ =>
            {
                var userData = this.Bind<UserDto>();

                // First login creates user
                if (!userManager.HasUsers())
                {
                    logger.Info("Creating user account {UserName}.", userData.UserName);
                    userManager.CreateUser(userData.UserName, userData.Password);
                }

                var user = userManager.GetUser(userData.UserName, userData.Password);

                if (user == null)
                {
                    logger.Warn("Invalid username/password: {UserName}.", userData.UserName);
                    return HttpStatusCode.Unauthorized;
                }

                var identity = new UserIdentity(user.UserName, user.Claims);
                var token = tokenizer.Tokenize(identity, Context);

                return new
                {
                    Token = token
                };
            };
        }
开发者ID:DNIDNL,项目名称:hadouken,代码行数:35,代码来源:AuthModule.cs

示例2: Initialize

        public void Initialize() {
            playlistManager = new PlaylistManager(new PlaylistRepository(new EFDbContext(ContextEnum.BeatBuddyTest)), new UserRepository(new EFDbContext(ContextEnum.BeatBuddyTest)));
            userManager = new UserManager(new UserRepository(new EFDbContext(ContextEnum.BeatBuddyTest)));
            user = userManager.CreateUser("[email protected]", "matthias", "test", "acidshards", "");
            playlist = playlistManager.CreatePlaylistForUser("testplaylist", "gekke playlist om te testen", "125", 5, true, "", user);

            trackProvider = new YouTubeTrackProvider();
            albumArtProvider = new BingAlbumArtProvider();

            playlistControllerWithAuthenticatedUser = MyWebApi.Controller<PlaylistController>()
               .WithResolvedDependencyFor<IPlaylistManager>(playlistManager)
               .WithResolvedDependencyFor<IUserManager>(userManager)
               .WithResolvedDependencyFor<ITrackProvider>(trackProvider)
               .WithResolvedDependencyFor<IAlbumArtProvider>(albumArtProvider)
               .WithAuthenticatedUser(
                u => u.WithIdentifier("NewId")
                      .WithUsername(user.Email)
                      .WithClaim(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Email, user.Email))
                      .WithClaim(new System.Security.Claims.Claim("sub", user.Email))
               );
            Track metallicaTrack = new Track()
            {
                Artist = "Metallica",
                Title = "Master of Puppets (live)",
                CoverArtUrl = "",
                Duration = 800,
                TrackSource = new TrackSource
                {
                    SourceType = SourceType.YouTube,
                    Url = "https://www.youtube.com/watch?v=kV-2Q8QtCY4",
                    TrackId = "kV-2Q8QtCY4"
                }
            };
            Track nickelbackTrack = new Track()
            {
                Artist = "Nickelback",
                Title = "How You Remind Me",
                CoverArtUrl = "",
                Duration = 400,
                TrackSource = new TrackSource
                {
                    SourceType = SourceType.YouTube,
                    Url = "https://www.youtube.com/watch?v=1cQh1ccqu8M",
                    TrackId = "1cQh1ccqu8M"
                }
            };

            _addedMetallicaTrack = playlistManager.AddTrackToPlaylist(playlist.Id, metallicaTrack);
            _addedNickelbackTrack = playlistManager.AddTrackToPlaylist(playlist.Id, nickelbackTrack);
            
        }
开发者ID:BeatBuddy,项目名称:beatbuddy_webapp,代码行数:51,代码来源:PlaylistControllerTest.cs

示例3: Create

 public static ContainerUser Create(IUserManager userManager, string containerId)
 {
     var credentials = userManager.CreateUser(BuildContainerUserName(containerId));
     return new ContainerUser(userManager, credentials);
 }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:5,代码来源:ContainerUser.cs


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