<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Oeffentlich\PasswortAnfordern\SendePasswortAnfordern;

class SendePasswortAnfordernController extends \Kufer\KuferTools\Basis\Controller\Controller
{
  protected function getUseCase()
  {
    return new SendePasswortAnfordernUseCase(
            $this->getRequestObj()
    );
  }
  
  protected function getRequestObj()
  {
    $filter = \FilterFactory::getFilterClass();
    $captcha = new \SimpleCaptcha();
    
    $request = new SendePasswortAnfordernRequest();
    $request->login = $filter->filterLogin(\PostOperations::getVarValue('login'));
    $request->passwort = trim(\PostOperations::getVarValue('password'));
    $request->passwortWiederholt = trim(\PostOperations::getVarValue('password_repeat'));
    
    
    $request->captchaOk = $captcha->isValid(null, true, 'tedit', true);
    
    $action = $this->getActionVal();
    $request = $this->handleXsrf($request, $action);
    return $request;
  }
  
  function getPresenter($pUseCaseResponse)
  {
    return new SendePasswortAnfordernPresenter($pUseCaseResponse);
  }
}