Example #1
0
        public async Task <IdentityUserDto> Create(IdentityUserCreateDto input)
        {
            var user = new IdentityUser(
                GuidGenerator.Create(),
                input.OrgId,
                input.UserName,
                input.Email,
                CurrentTenant.Id
                );

            input.MapExtraPropertiesTo(user);

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

            var dto = ObjectMapper.Map <IdentityUser, IdentityUserDto>(user);

            foreach (var jid in input.Jobs)
            {
                await _userJobsRepository.InsertAsync(new UserJobs(user.Id, jid));
            }

            await CurrentUnitOfWork.SaveChangesAsync();

            return(dto);
        }
Example #2
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);
    }
 public virtual async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
 {
     return(await RequestAsync <IdentityUserDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue
     {
         { typeof(IdentityUserCreateDto), input }
     }));
 }
Example #4
0
        public override async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var userCount        = (await FeatureChecker.GetOrNullAsync(AbpVnextFeatures.UserCount)).To <int>();
            var currentUserCount = await UserRepository.GetCountAsync();

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

            return(await base.CreateAsync(input));
        }
Example #5
0
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public virtual async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            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);

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }
Example #6
0
        public virtual async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            try
            {
                await IdentityOptions.SetAsync();
            }
            catch (Exception e)
            {
                throw;
            }

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

            input.MapExtraPropertiesTo(user);

            // TODO: this is another issue.
            // It throws an error without casting the type int to enum type before saving the user
            var      userType = user.GetProperty <int>("Type");
            UserType type     = (UserType)userType;

            user.SetProperty("Type", type);

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

            (await UserManager.UpdateAsync(user)).CheckErrors();

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }
Example #7
0
 public Task <IdentityUserDto> Create(IdentityUserCreateDto input)
 {
     return(_userAppService.Create(input));
 }
Example #8
0
 public async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
 {
     return(await _identityUserAppService.CreateAsync(input));
 }
Example #9
0
 public virtual Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
 {
     return(_userAppService.CreateAsync(input));
 }
Example #10
0
 public override async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
 {
     return(await base.CreateAsync(input));
 }
Example #11
0
 /// <summary>
 /// 创建用户
 /// </summary>
 /// <param name="parameters">请求参数</param>
 /// <returns>Task&lt;IdentityUserDto&gt;.</returns>
 public virtual Task <IdentityUserDto> Create(IdentityUserCreateDto parameters)
 {
     return(_userAppService.CreateAsync(parameters));
 }