コード例 #1
0
        public async Task CreateAsync()
        {
            //Arrange

            var input = new IdentityUserCreateDto
            {
                UserName       = Guid.NewGuid().ToString(),
                Email          = CreateRandomEmail(),
                LockoutEnabled = true,
                PhoneNumber    = CreateRandomPhoneNumber(),
                Password       = "******",
                RoleNames      = new[] { "moderator" }
            };

            //Act

            var result = await _userAppService.CreateAsync(input);

            //Assert

            result.Id.ShouldNotBe(Guid.Empty);
            result.UserName.ShouldBe(input.UserName);
            result.Email.ShouldBe(input.Email);
            result.LockoutEnabled.ShouldBe(input.LockoutEnabled);
            result.PhoneNumber.ShouldBe(input.PhoneNumber);

            var user = await _userRepository.GetAsync(result.Id);

            user.Id.ShouldBe(result.Id);
            user.UserName.ShouldBe(input.UserName);
            user.Email.ShouldBe(input.Email);
            user.LockoutEnabled.ShouldBe(input.LockoutEnabled);
            user.PhoneNumber.ShouldBe(input.PhoneNumber);
        }
コード例 #2
0
        public async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var user = new IdentityUser(GuidGenerator.Create(), input.UserName, CurrentTenant.Id);

            CheckIdentityErrors(await _userManager.CreateAsync(user, input.Password));
            await UpdateUserByInput(user, input);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }
コード例 #3
0
        public virtual async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id);

            (await _userManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors();
            await UpdateUserByInput(user, input).ConfigureAwait(false);

            await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }
コード例 #4
0
        public override async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var userCount        = (await FeatureChecker.GetOrNullAsync(HelloAbpFeatures.UserCount)).To <int>();
            var currentUserCount = await UserRepository.GetCountAsync();

            if (currentUserCount >= userCount)
            {
                throw new UserFriendlyException(_localizer["Feature:UserCount.Maximum", userCount]);
            }

            return(await base.CreateAsync(input));
        }
コード例 #5
0
        public async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id);

            (await _userManager.CreateAsync(user, input.Password)).CheckErrors();
            await UpdateUserByInput(user, input);

            await CurrentUnitOfWork.SaveChangesAsync();

            //Send activation email
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(user, input.Password);
            }

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }
コード例 #6
0
ファイル: IdentityUserAppService.cs プロジェクト: yomore/abp
        public virtual async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            await IdentityOptions.SetAsync();

            var user = new IdentityUser(
                GuidGenerator.Create(),
                input.UserName,
                input.Email,
                CurrentTenant.Id
                );

            input.MapExtraPropertiesTo(user);

            (await UserManager.CreateAsync(user, input.Password)).CheckErrors();
            await UpdateUserByInput(user, input);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }
コード例 #7
0
 public virtual Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
 {
     return(UserAppService.CreateAsync(input));
 }