Пример #1
0
        public ICommandResult Handle(UserChangePasswordCommand command)
        {
            var commandResult = new UserChangePasswordCommandResult();

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

            //Validações de coisas que vão em repositório
            var personFoundBySerialKey = _personRepository.GetBySerialKey(command.SerialKey);

            //var device = _deviceRepository.GetByDeviceIdentificationIncludingPerson(command.Identification);

            //if (!(command.HasFoundPerson(personFoundBySerialKey) && command.HasFoundDevice(device) && command.HasFoundDeviceBelongsToPerson(device, personFoundBySerialKey)))
            if (!(command.HasFoundPerson(personFoundBySerialKey)))
            {
                return(commandResult);
            }

            var personFoundByUsernameAndPassword =
                _personRepository.GetByEmailAndPassword(personFoundBySerialKey.Email, _passwordService.Encrypt(command.OldPassword));

            if (!(command.HasFoundAuthorizedUser(personFoundByUsernameAndPassword) && command.HasActiveUser(personFoundByUsernameAndPassword)))
            {
                return(commandResult);
            }

            return(commandResult);
        }
Пример #2
0
        public IHttpActionResult UserChangePassword(UserChangePasswordCommand command)
        {
            UserChangePasswordCommandResult result = (UserChangePasswordCommandResult)_handlerChangePassword.Handle(command);

            return(Response(result));
        }