Пример #1
0
 function endpoint($request = array())
 {
     if (count($request) == 0) {
         $request = $this->openid_response();
     }
     print_r($request);
     api_session::set('openid_request', $request);
     if (isset($request['openid.mode'])) {
         switch ($request['openid.mode']) {
             case 'associate':
                 echo "Associate";
                 $this->openid_provider_association_response($request);
                 return;
             case 'checkid_immediate':
             case 'checkid_setup':
                 return $this->openid_provider_authentication_response($request);
             case 'check_authentication':
                 $this->openid_provider_verification_response($request);
                 break;
         }
     }
 }
Пример #2
0
 public function login($username, $password)
 {
     if ($username === '' && $password === '') {
         $username = $this->request->getParam('username');
         $password = $this->request->getParam('password');
     }
     //print_r($username);
     if (!empty($username)) {
         if ($this->checkAuth()) {
             $this->logout();
         }
         $crudColumns = $this->getConfiguredColumns();
         //print_r($crudColumns);
         // $hash = $this->getOpt('hash');
         //$sql = 'SELECT SUBSTR('.$crudColumns['password'].',1,'.(int)$hash['saltLength'].')
         //    FROM '.$this->config->crud['crudTable'].'
         //    WHERE '.$crudColumns['username'].' = '.$this->db->quote($username);
         //$stmt = $this->db->prepare($sql);
         //$stmt->execute(array());
         //$salt = $stmt->fetchColumn();
         //if (empty($salt)) {
         //    api_log::log(api_log::INFO, 'Salt not found in Database');
         //}
         //$hashedPW = api_helpers_hashHelper::crypt_pass($password, $salt, $hash);
         $select = array();
         foreach ($crudColumns as $alias => $val) {
             $select[] = $val . ' AS ' . $alias;
         }
         $select = implode(' ,', $select);
         $sql = 'SELECT ' . $select . ' FROM ' . $this->config->pam['table'] . ' WHERE ' . $crudColumns['username'] . ' = :username';
         //echo $sql;
         api_log::log(api_log::DEBUG, $sql);
         $stmt = $this->db->prepare($sql);
         $sqlParams = array('username' => $username);
         $stmt->execute($sqlParams);
         //echo "Here";
         //print_r($sqlParams);
         $userData = $stmt->fetch(PDO::FETCH_ASSOC);
         //print_r($userData);
         // Check password
         if (empty($userData)) {
             api_log::log(api_log::INFO, 'Credentials not correct');
             //    echo "Credential not correct";
         } else {
             if (!$this->checkPassword($password, $userData['password'])) {
                 api_log::log(api_log::INFO, 'Password not correct');
                 //              echo "Passwords wrong";
             } else {
                 session_regenerate_id(true);
                 unset($userData['password']);
                 //            echo "<br />";
                 //            print_r($this->config->appname);
                 //            echo "<br />";
                 //$_SESSION[$this->config->appname]['user'] = $userData;
                 api_log::log(api_log::INFO, 'Login Successful creating user session');
                 api_session::set('user', $userData);
             }
         }
     }
     return $this->checkAuth();
 }