Exemple #1
0
        private async Task <bool> UpdateUser(CreateOrEditUserInput input)
        {
            try
            {
                var user = await UserManager.FindByIdAsync(input.Id);

                ObjectMapper.Map(input, user);

                var result = await UserManager.UpdateAsync(user);

                if (!input.RequestPasswordChange)
                {
                    return(result.Succeeded);
                }

                var token = await UserManager.GeneratePasswordResetTokenAsync(user);

                var passwordChangeResult = await UserManager.ResetPasswordAsync(user, token, input.Password);

                return(passwordChangeResult.Succeeded && result.Succeeded);
            }
            catch (Exception e)
            {
                Logger.LogError(e.ToString());
                throw;
            }
        }
        public async Task LoadUser(string id)
        {
            IsEdit = !string.IsNullOrEmpty(id);
            Input  = await UserService.GetUserForEdit(id);

            StateHasChanged();
        }
Exemple #3
0
        private async Task <bool> CreateUser(CreateOrEditUserInput input)
        {
            var user = ObjectMapper.Map <CodeHubUser>(input);

            user.Id = Guid.NewGuid().ToString();
            var result = await UserManager.CreateAsync(user, input.Password);

            return(result.Succeeded);
        }
Exemple #4
0
        public async Task <bool> CreateOrEditUser(CreateOrEditUserInput input)
        {
            if (string.IsNullOrEmpty(input.Id))
            {
                return(await CreateUser(input));
            }

            return(await UpdateUser(input));
        }
Exemple #5
0
 public virtual async Task Create(CreateOrEditUserInput input)
 {
     await this._userManager.CreateAsync(
         input.EntityDto.UserName,
         input.Password,
         input.EntityDto.Nickname,
         input.EntityDto.PhoneNumber,
         input.EntityDto.PhoneNumberConfirmed,
         input.EntityDto.Email,
         input.EntityDto.EmailConfirmed,
         input.EntityDto.LockoutEnabled,
         input.EntityDto.IsActive,
         input.EntityDto.TwoFactorEnabled
         );
 }
Exemple #6
0
        public virtual async Task Update(CreateOrEditUserInput input)
        {
            if (!input.EntityDto.Id.HasValue)
            {
                return;
            }

            await this._userManager.UpdateAsync(
                input.EntityDto.Id,
                input.Password,
                input.EntityDto.Nickname,
                input.EntityDto.PhoneNumber,
                input.EntityDto.PhoneNumberConfirmed,
                input.EntityDto.Email,
                input.EntityDto.EmailConfirmed,
                input.EntityDto.LockoutEnabled,
                input.EntityDto.IsActive,
                input.EntityDto.TwoFactorEnabled
                );
        }