*/ final class UpdateCustomerPassword implements Action { public function __construct( private readonly AppCustomerAuthService $authService, private readonly CrmService $crmService ) { } #[\Override] public function __invoke(ActionInput $input): UpdateCustomerPasswordOutput { Assert::isInstanceOf($input, UpdateCustomerPasswordInput::class); $hashcode = $this->authService->getCustomerAsMandatory()->hashcode; $crmCustomer = $this->crmService->getCustomerFromHashCode( $hashcode ); if ($crmCustomer instanceof CrmCustomer === false) { return new UpdateCustomerPasswordOutput(false); } try { $result = $this->crmService->changePassword( $crmCustomer, $input->currentPassword, $input->newPassword, ); return new UpdateCustomerPasswordOutput($result); } catch (\Throwable $e) { report($e); return new UpdateCustomerPasswordOutput(false); } } }