7 use Elgg\Traits\TimeUsing;
42 $token = $this->crypto->getRandomString(32,
Crypto::CHARS_HEX);
43 $expires = $this->getCurrentTime(
"+{$expires} minutes");
52 return $this->database->insertData($insert) ?
$token :
false;
67 return $this->database->getData($select);
78 $select =
Select::fromTable(self::TABLE_NAME);
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;
96 $delete = Delete::fromTable(self::TABLE_NAME);
99 return (
bool) $this->database->deleteData(
$delete);
108 $delete = Delete::fromTable(self::TABLE_NAME);
111 return $this->database->deleteData(
$delete);
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
Query builder for fetching data from the database.
static fromTable(string $table, ?string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
Manage the contents of the users_apisessions table.
getUserTokens(int $user_guid)
Get all tokens attached to a user.
createToken(int $user_guid, int $expires=60)
Obtain a token for a user.
removeExpiresTokens()
Remove expired tokens.
removeToken(string $token)
Remove user token.
validateToken(string $token)
Validate that a given token is still valid.
__construct(protected Database $database, protected Crypto $crypto)
Create a new table handler.
const ELGG_VALUE_TIMESTAMP