//[ValidateAntiForgeryToken]
        public async Task <IActionResult> SetPassword(SetPasswordModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model).WithError(JoinWithHtmlLineBreak(ModelState.GetErrorMessages())));
            }

            try
            {
                var result = await _userService.SetPasswordAsync(model.UserId, model.Password);

                return(result.Succeeded
                    ? RedirectToDefault.WithSuccess("Password was set with success.")
                    : View(model).WithError(JoinWithHtmlLineBreak(result.GetAllErrors())));
            }
            catch (ValidationException validationException)
            {
                return(View(model).WithError(validationException.Message));
            }
            catch (Exception exception)
            {
                _appLogger.LogError(exception);
                return(View(model).WithError(MessagesOptions.GenericErrorMessage));
            }
        }
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> EditUser(EditUserModel model)
        {
            if (!model.WithPasswordChange)
            {
                ModelState
                .ClearKey(nameof(model.CurrentPassword))
                .ClearKey(nameof(model.NewPassword))
                .ClearKey(nameof(model.NewPasswordRepeat));
            }

            if (!ModelState.IsValid)
            {
                return(View(model).WithError(JoinWithHtmlLineBreak(ModelState.GetErrorMessages())));
            }

            try
            {
                var result = model.WithPasswordChange
                    ? await _userService.EditAsync(model.UserId, model.UserName, model.CurrentPassword, model.NewPassword)
                    : await _userService.EditAsync(model.UserId, model.UserName);

                if (result.Succeeded)
                {
                    await _signInManager.SignOutAsync();

                    await _signInManager.SignInAsync(_currentUserAccessor.ApplicationUser, true);
                }

                return(result.Succeeded
                    ? RedirectToDefault.WithSuccess("Edited with success.")
                    : View(model).WithError(JoinWithHtmlLineBreak(result.GetAllErrors())));
            }
            catch (ValidationException validationException)
            {
                return(View(model).WithError(validationException.Message));
            }
            catch (Exception exception)
            {
                _appLogger.LogError(exception);
                return(View(model).WithError(MessagesOptions.GenericErrorMessage));
            }
        }