public async Task <IActionResult> ChangePassword(ChangePasswordModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = _dispatcher.Dispatch(new GetUserQuery {
                Id = model.Id
            });
            var token = await _userManager.GeneratePasswordResetTokenAsync(user);

            var rs = await _userManager.ResetPasswordAsync(user, token, model.ConfirmPassword);

            if (rs.Succeeded)
            {
                return(RedirectToAction(nameof(Profile), new { model.Id }));
            }

            foreach (var error in rs.Errors)
            {
                ModelState.AddModelError(string.Empty, error.Description);
            }

            return(View(ChangePasswordModel.FromEntity(user)));
        }
        public IActionResult ChangePassword(Guid id)
        {
            var user = _dispatcher.Dispatch(new GetUserQuery {
                Id = id, AsNoTracking = true
            });

            return(View(ChangePasswordModel.FromEntity(user)));
        }
Example #3
0
        public async Task <IActionResult> ChangePassword(Guid id)
        {
            var user = await _dispatcher.DispatchAsync(new GetUserQuery { Id = id, AsNoTracking = true });

            return(View(ChangePasswordModel.FromEntity(user)));
        }
        public IActionResult ChangePassword(Guid id)
        {
            var user = _dbContext.Set <User>().FirstOrDefault(x => x.Id == id);

            return(View(ChangePasswordModel.FromEntity(user)));
        }