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

namespace Kufer\KuferTools\Oeffentlich\LoginAnfordern\SendeDozAutoLoginAnfordern;

class SendeDozAutoLoginAnfordernController extends \Kufer\KuferTools\Basis\Controller\Controller
{
  protected function getUseCase()
  {
    return new SendeDozAutoLoginAnfordernUseCase(
            $this->getRequestObj(),
            \ToolSettingsAPI::getToolSettings(0)
    );
  }
  
  protected function getRequestObj()
  {
    $request = new SendeDozAutoLoginAnfordernRequest();
    $request->name = \trim(\PostOperations::getVarValue('name'));
    $request->vorname = \trim(\PostOperations::getVarValue('vorname'));
    $request->email = \trim(\PostOperations::getVarValue('email'));
    
    $captcha = new \SimpleCaptcha();
    $request->captchaOk = $captcha->isValid(null, true, 'tedit', true);
    $request->passwort = trim(\PostOperations::getVarValue('password'));
    $request->passwortWiederholt = trim(\PostOperations::getVarValue('password_repeat'));
    
    $action = $this->getActionVal();
    $request = $this->handleXsrf($request, $action);
    
    return $request;
  }
  
  function getPresenter($pUseCaseResponse)
  {
    return new SendeDozAutoLoginAnfordernPresenter($pUseCaseResponse);
  }
}