Example #1
0
 /**
  * pub login action
  * - create login from
  * - check for post
  * - validate form values
  * - check if user found
  * - if auth rediect else display login form
  */
 public function loginAction()
 {
     $login = new LoginForm();
     $this->authError = false;
     if ($this->isPost() && $login->form->validate()) {
         $usr = ActiveModels\User::find_by_username_or_email(trim($_POST['username']), trim($_POST['username']));
         if (!empty($usr)) {
             $auth = Hash::GetHmac(trim($_POST['password']), $usr->salt, $usr->hash);
             if ($auth == true) {
                 Sess::Invoke($usr);
                 $login->form->clearSession();
                 $login->form->process();
             }
         }
         $this->authError = true;
     }
     $this->form = $login->getForm();
 }