コード例 #1
0
ファイル: Login.php プロジェクト: juliogallardo1326/proc
 /**
  * Execute a command and return a response. Does not render
  * @param IRequest $Request
  * @throws \Exception
  * @return IResponse the execution response
  */
 function execute(IRequest $Request)
 {
     $SessionRequest = $Request;
     if (!$SessionRequest instanceof ISessionRequest) {
         throw new \Exception("Session required");
     }
     $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLHeaderScript(__DIR__ . '/assets/account.js'), new HTMLHeaderStyleSheet(__DIR__ . '/assets/account.css'), new HTMLElement('fieldset', 'fieldset-create-account', new HTMLElement('legend', 'legend-account', self::TITLE), new HTMLElement('label', null, "Choose a Account Type<br/>", new HTMLInputField(self::PARAM_ACCOUNT_NAME, new RequiredValidation())), "<br/><br/>", new HTMLElement('label', null, "Status<br/>", new HTMLInputField(self::PARAM_ACCOUNT_PASSWORD, null, 'password', new RequiredValidation())), "<br/><br/>Login:<br/>", new HTMLButton('submit', 'Login', 'submit')), "<br/>");
     $Form->setFormValues($Request);
     if (!$Request instanceof IFormRequest) {
         return $Form;
     }
     $Form->validateRequest($Request);
     $AccountEntry = AccountEntry::search($Request[self::PARAM_ACCOUNT_NAME]);
     $Account = $AccountEntry->getAccount();
     $Account->assertPassword($Request[self::PARAM_ACCOUNT_PASSWORD]);
     $Account->startSession($SessionRequest);
     return new RedirectResponse(ManageAccount::getRequestURL($AccountEntry->getID()), "Logged in successfully. Redirecting...", 5);
 }