Example #1
0
 public function run()
 {
     if (Request::is('post')) {
         $this->validateToken();
     }
     foreach ($this->fields as $field) {
         if ($field instanceof Label) {
             continue;
         }
         foreach ($field->getValidatorAttributes() as $rule) {
             if (stripos($rule, 'requiredWith:') !== false) {
                 if (!$this->requiredWith($field->getName(), str_replace('requiredWith:', '', $rule))) {
                     $this->passed = false;
                     break;
                 }
             } elseif (stripos($rule, 'requiredWithout:') !== false) {
                 if (!$this->requiredWithout($field->getName(), str_replace('requiredWithout:', '', $rule))) {
                     $this->passed = false;
                     break;
                 }
             } elseif (!$this->{$rule}($field->getName())) {
                 $this->passed = false;
                 break;
             }
         }
         Session::set('__forminputs', $this->postVars);
     }
     Session::set('__formerrors', $this->errors);
     return $this->passed;
 }
Example #2
0
 public function loginQuery(callable $query)
 {
     $user = SQL::table(AUTH_TABLE)->select();
     $query($user);
     $user = $user->first();
     if ($user) {
         Session::set('__auth_user', $user);
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * Generate a form token
  *
  * @return string
  */
 public static function token()
 {
     $token = str_random(9);
     Session::set('__formtoken', $token);
     return $token;
 }