private function populateWithPost($obj)
 {
     $post = $_POST;
     foreach ($post as $var => $value) {
         $var = strip_tags($var);
         $value = strip_tags($value);
         if ($var == \Framework\Config\Config::ACSRF_FIELD_NAME) {
             continue;
         }
         if (true) {
             if (is_array($value)) {
                 $obj->{$var} = array_map('trim', $value);
             } else {
                 $obj->{$var} = trim($value);
             }
         } else {
             //throw new \Exception("Unexpected value for $var from input", 400);
             $this->addError("{$var} is invalid");
             $this->isValid = false;
         }
         if (!\Framework\Core\Csrf::validateToken()) {
             //throw new \Exception("Anti-Forgery token does not match", 400);
             $this->addError("Anti-Forgery token does not match");
             $this->isValid = false;
         }
     }
 }
Exemple #2
0
  	<?php 
echo $model->success ? $model->ListSuccessMessages() : '';
?>
  </div>

    <span href="#" class="button" id="toggle-login">Log in</span>

<div id="login">
  <div id="triangle"></div>
  <h1>Log in</h1>
  <form action="" method="post">
    <input type="text" name="username" id="username" placeholder="Username">
    <input type="password" name="password" id="password" placeholder="Password">
    <input type='hidden' value= <?php 
\Framework\Core\Csrf::generate();
echo \Framework\Core\Csrf::getToken();
?>
 name= <?php 
echo \Framework\Config\Config::ACSRF_FIELD_NAME;
?>
 />
    <input type="submit" value="Log in" />
	
	<?php 
if ($model->error) {
    ?>
    <div class='errors-box-cont col-xs-12'>
	<?php 
    echo $model->error ? $model->ListErrors() : '';
    ?>
  </div>