Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/query/PhabricatorAuthSessionQuery.php
<?php | <?php | ||||
final class PhabricatorAuthSessionQuery | final class PhabricatorAuthSessionQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $identityPHIDs; | private $identityPHIDs; | ||||
private $sessionKeys; | |||||
private $sessionTypes; | |||||
public function withIdentityPHIDs(array $identity_phids) { | public function withIdentityPHIDs(array $identity_phids) { | ||||
$this->identityPHIDs = $identity_phids; | $this->identityPHIDs = $identity_phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withSessionKeys(array $keys) { | |||||
$this->sessionKeys = $keys; | |||||
return $this; | |||||
} | |||||
public function withSessionTypes(array $types) { | |||||
$this->sessionTypes = $types; | |||||
return $this; | |||||
} | |||||
protected function loadPage() { | protected function loadPage() { | ||||
$table = new PhabricatorAuthSession(); | $table = new PhabricatorAuthSession(); | ||||
$conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
$data = queryfx_all( | $data = queryfx_all( | ||||
$conn_r, | $conn_r, | ||||
'SELECT * FROM %T %Q %Q %Q', | 'SELECT * FROM %T %Q %Q %Q', | ||||
$table->getTableName(), | $table->getTableName(), | ||||
Show All 31 Lines | protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
if ($this->identityPHIDs) { | if ($this->identityPHIDs) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'userPHID IN (%Ls)', | 'userPHID IN (%Ls)', | ||||
$this->identityPHIDs); | $this->identityPHIDs); | ||||
} | } | ||||
if ($this->sessionKeys) { | |||||
$hashes = array(); | |||||
foreach ($this->sessionKeys as $session_key) { | |||||
$hashes[] = PhabricatorHash::digest($session_key); | |||||
} | |||||
$where[] = qsprintf( | |||||
$conn_r, | |||||
'sessionKey IN (%Ls)', | |||||
$hashes); | |||||
} | |||||
if ($this->sessionTypes) { | |||||
$clauses = array(); | |||||
foreach ($this->sessionTypes as $session_type) { | |||||
$clauses[] = qsprintf( | |||||
$conn_r, | |||||
'type LIKE %>', | |||||
$session_type.'-'); | |||||
} | |||||
$where[] = '('.implode(') OR (', $clauses).')'; | |||||
} | |||||
$where[] = $this->buildPagingClause($conn_r); | $where[] = $this->buildPagingClause($conn_r); | ||||
return $this->formatWhereClause($where); | return $this->formatWhereClause($where); | ||||
} | } | ||||
public function getPagingColumn() { | public function getPagingColumn() { | ||||
return 'sessionKey'; | return 'sessionKey'; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorApplicationAuth'; | return 'PhabricatorApplicationAuth'; | ||||
} | } | ||||
} | } |