Ejemplo n.º 1
0
 public function authentication($username, $password)
 {
     $session = $this->getSession();
     $user = new Sam_Model_Account();
     //echo ( $user->select ()->where ( 'loginid = ?', $username )->where ( 'pwd = ?', $password ) );
     $userLogon = $user->fetchRow($user->select()->where('loginid = ?', $username)->where('pwd = ?', $password));
     if ($userLogon == null) {
         //print_r($userLogon);
         //App_Log::get()->authenLog('',$username,(bool)$userLogon->master,'FAILURE','Login Id was not found or Password was not correct');
         return self::FAILURE;
     } elseif ($userLogon->getStatus() != 1) {
         App_Log::get()->authenLog('', $username, (bool) $userLogon->master, 'FAILURE', 'Your User Account has been disabled or expired');
         return self::FAILURE;
     } else {
         App_Env::setSession('userFullname', $userLogon->getFullname());
         //$_SESSION['SES_USER_FULLNAME'] = $userLogon->getFullname();
         App_Env::setSession('userEmail', $userLogon->getEmail());
         //$_SESSION['SES_USER_EMAIL'] = $userLogon->getEmail();
         App_Env::setSession('userId', $userLogon->id);
         App_Env::setSession('userGroupId', $userLogon->groupid);
         App_Env::setSession("userType", 'admin');
         App_Env::setSession("master", (bool) $userLogon->master);
         $this->setIdentity($userLogon->id);
         $session->isLoginSuccess = true;
         Sam_Acl::getInstance()->setUser($userLogon);
         App_Env::createUserTemporaryFolder();
         try {
             $userLogon->setLastlogin(new DateTime());
             $userLogon->save();
         } catch (Exception $e) {
         }
         App_Log::get()->authenLog('', $userLogon, (bool) $userLogon->master, 'SUCCESS', '');
         return self::SUCCESS;
     }
 }