32 protected $table =
'users_apisessions';
54 $token = $this->crypto->getRandomString(32, Crypto::CHARS_HEX);
64 if ($this->database->insertData($insert)) {
81 ->where($select->compare(
'user_guid',
'=', $user_guid,
ELGG_VALUE_GUID));
83 return $this->database->getData($select);
97 ->andWhere($select->compare(
'expires',
'>', $this->getCurrentTime()->getTimestamp(),
ELGG_VALUE_TIMESTAMP));
99 $row = $this->database->getDataRow($select);
104 return (
int) $row->user_guid;
118 return (
bool) $this->database->deleteData(
$delete);
130 return $this->database->deleteData(
$delete);
Manage the contents of the users_apisessions table.
trait TimeUsing
Adds methods for setting the current time (for testing)
getCurrentTime($modifier= '')
Get the (cloned) time.
static intoTable($table)
{}
createToken(int $user_guid, int $expires=60)
Obtain a token for a user.
removeExpiresTokens()
Remove expired tokens.
getUserTokens(int $user_guid)
Get all tokens attached to a user.
const ELGG_VALUE_TIMESTAMP
static fromTable($table, $alias=null)
{}
__construct(Database $database, Crypto $crypto)
Create a new table handler.
removeToken(string $token)
Remove user token.
validateToken(string $token)
Validate that a given token is still valid.
static fromTable($table, $alias=null)
{}