42 $token = $this->crypto->getRandomString(32, Crypto::CHARS_HEX);
52 return $this->database->insertData($insert) ?
$token :
false;
65 ->where($select->compare(
'user_guid',
'=', $user_guid,
ELGG_VALUE_GUID));
67 return $this->database->getData($select);
81 ->andWhere($select->compare(
'expires',
'>', $this->getCurrentTime()->getTimestamp(),
ELGG_VALUE_TIMESTAMP));
83 $row = $this->database->getDataRow($select);
85 return $row ? (int) $row->user_guid :
false;
99 return (
bool) $this->database->deleteData(
$delete);
111 return $this->database->deleteData(
$delete);
Manage the contents of the users_apisessions table.
trait TimeUsing
Adds methods for setting the current time (for testing)
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
getCurrentTime($modifier= '')
Get the (cloned) time.
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.
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
const ELGG_VALUE_TIMESTAMP
removeToken(string $token)
Remove user token.
static fromTable(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
__construct(protected Database $database, protected Crypto $crypto)
Create a new table handler.
validateToken(string $token)
Validate that a given token is still valid.