public async Task <bool> Handle(AdminChangePasswordCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var user = await _userService.FindByNameAsync(request.Username);

            if (user == null)
            {
                await Bus.RaiseEvent(new DomainNotification("Username", "User not found"));

                return(false);
            }

            var success = await _userService.ResetPasswordAsync(request.Username, request.Password);

            if (success)
            {
                await Bus.RaiseEvent(new AdminChangedPasswordEvent(user.Id, request.Username));

                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 public async Task <ActionResult <bool> > AdminChnagePassword([FromBody] AdminChangePasswordCommand request)
 {
     return(Ok(await Mediator.Send(request)));
 }