Esempio n. 1
0
File: Auth.php Progetto: h1soft/h
 public function login($username, $password)
 {
     if (empty($username) || empty($password)) {
         return false;
     }
     //check db
     $db = \hmvc\Db\Db::getConnection();
     $password = \hmvc\Utils\Crypt::password($password);
     $user = $db->getOne("admin", "username='******' and password='******'");
     if ($user) {
         $this->setId($user['id']);
         $this->setName($user['username']);
         $db->update('admin', array('last_login' => time(), 'login_ip' => Application::app()->request()->ipAddress()), "id='{$user['id']}'");
         //            $this->session->set('auth.id', $this->getId());
         //            $this->session->set('auth.name', $this->getName());
         return true;
     }
     return false;
 }