code: public function editProfileAction()
      {
          // if the user is not logged in, we can't edit profile
          if (!$this->cmsAuthentication()->hasIdentity()) {
              // redirect to the login redirect route
              return $this->redirect()->toRoute($this->getOptions()->getLoginRoute());
          }
  
          $url = $this->url()->fromRoute(null, ['action' => 'edit-profile']);
  
          $prg = $this->prg($url, true);
          if ($prg instanceof ResponseInterface) {
              return $prg;
          }
  
          $post = $prg;
  
          $form = $this->getUserService()->getEditProfileForm();
          $identity = $this->cmsAuthentication()->getIdentity();
          $form->bind($identity);
          $form->setAttribute('action', $url);
  
          if ($post && $form->setData($post)->isValid()) {
  
              $result = $this->getUserService()->editProfile($identity);
  
              // Return early if an user service returned a response
              if ($result instanceof ResponseInterface) {
                  return $result;
              } elseif ($result) {
                  $fm = $this->flashMessenger();
                  $fm->setNamespace($form->getName() . '-' . $fm::NAMESPACE_SUCCESS)
                     ->addMessage($this->translate('Data has been successfully saved'));
              }
          }
  
          return new ViewModel(compact('form'));
      }
docs: Edit user profile action
  
  Displays user profile edit form
  
  @return ResponseInterface|ViewModel