Beispiel #1
0
        public ICommandResult Handle(UserForgotPasswordCommand command)
        {
            var commandResult = new UserForgotPasswordCommandResult();

            //Validações de coisas que não vão em repositório
            if (!(command.HasValidEmail()))
            {
                return(commandResult);
            }

            //Gera nova entidade

            //Trata fluxo demais regras
            var person = _personRepository.GetByEmail(command.Email);

            if (person != null)
            {
                string plainNewPassword = Guid.NewGuid().ToString().Substring(0, 7);
                string password         = _passwordService.Encrypt(plainNewPassword);
                person.SetPassword(password);

                _personRepository.Update(person);

                if (Commit())
                {
                    DomainEvent.Raise(new UserForgotPasswordRequestedEvent(person, plainNewPassword));

                    commandResult.SerialKey = person.SerialKey;
                }
            }

            return(commandResult);
        }
Beispiel #2
0
        public IHttpActionResult UserForgotPassword(UserForgotPasswordCommand command)
        {
            UserForgotPasswordCommandResult result = (UserForgotPasswordCommandResult)_handlerForgotPassword.Handle(command);

            return(Response(result));
        }
Beispiel #3
0
        public UserForgotPasswordCommand Build()
        {
            var authenticateUserCommand = new UserForgotPasswordCommand(_email);

            return(authenticateUserCommand);
        }