mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-17 21:12:14 +01:00
Delete token if it is past its lifetime
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
921198aad0
commit
6912299808
1 changed files with 12 additions and 1 deletions
|
|
@ -30,6 +30,9 @@ use OCP\IDBConnection;
|
|||
use OCP\Security\ISecureRandom;
|
||||
|
||||
class AssetMapper extends Mapper {
|
||||
/** @var int Limetime of a token is 10 minutes */
|
||||
const tokenLifeTime = 600;
|
||||
|
||||
/** @var ISecureRandom */
|
||||
private $random;
|
||||
|
||||
|
|
@ -80,6 +83,14 @@ class AssetMapper extends Mapper {
|
|||
throw new DoesNotExistException('No asset for token found');
|
||||
}
|
||||
|
||||
return Asset::fromRow($data);
|
||||
$asset = Asset::fromRow($data);
|
||||
|
||||
// Check the token lifetime
|
||||
if ($asset->getTimestamp() + self::tokenLifeTime < $this->time->getTime()) {
|
||||
$this->delete($asset);
|
||||
throw new DoesNotExistException('No asset for token found');
|
||||
}
|
||||
|
||||
return $asset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue