예제 #1
0
 /**
  * Port of function verify_authentication()
  *
  * @param  $username
  * @param  $password
  * @param  $md5password
  * @param  $md5password_utf
  * @return array|bool false if auth failed. User info array if auth successfully.
  */
 public static function verifyAuthentication($username, $password, $md5password, $md5password_utf)
 {
     // todo: we need to restore this method
     // $username = vB_String::stripBlankAscii($username, ' ');
     // See VBM-635: &#xxx; should be converted to windows-1252 extended char. This may
     // not happen if a browser submits the form. But from API or user manually input, it does.
     // See also vB_DataManager_User::verify_username()
     $username = vB_String::convertStringToCurrentCharset($username);
     $passwords = array();
     if (!empty($password)) {
         $passwords[] = array('password' => $password, 'encoding' => 'text');
     }
     if (!empty($md5password)) {
         $passwords[] = array('password' => $md5password, 'encoding' => 'md5');
     }
     if (!empty($md5password_utf)) {
         $passwords[] = array('password' => $md5password_utf, 'encoding' => 'md5');
     }
     $loginlib = vB_Library::instance('login');
     $auth = $loginlib->verifyPassword($username, $passwords);
     if (!$auth['auth']) {
         return false;
     }
     $session = vB::getRequest()->createSessionForUser($auth['userid']);
     $sessionUserInfo = $session->fetch_userinfo();
     $return_value = array('userid' => $auth['userid'], 'password' => $auth['remembermetoken'], 'lastvisit' => $sessionUserInfo['lastvisit'], 'lastactivity' => $sessionUserInfo['lastactivity']);
     return $return_value;
 }