diff options
Diffstat (limited to 'lib/private/Authentication')
4 files changed, 15 insertions, 3 deletions
diff --git a/lib/private/Authentication/Token/DefaultToken.php b/lib/private/Authentication/Token/DefaultToken.php index 6b859d7d063..78b5c2d6116 100644 --- a/lib/private/Authentication/Token/DefaultToken.php +++ b/lib/private/Authentication/Token/DefaultToken.php @@ -49,6 +49,11 @@ class DefaultToken extends Entity implements IToken { /** * @var int */ + protected $type; + + /** + * @var int + */ protected $lastActivity; public function getId() { diff --git a/lib/private/Authentication/Token/DefaultTokenMapper.php b/lib/private/Authentication/Token/DefaultTokenMapper.php index d54d2489399..f4d979183e6 100644 --- a/lib/private/Authentication/Token/DefaultTokenMapper.php +++ b/lib/private/Authentication/Token/DefaultTokenMapper.php @@ -50,9 +50,11 @@ class DefaultTokenMapper extends Mapper { */ public function invalidateOld($olderThan) { $sql = 'DELETE FROM `' . $this->getTableName() . '` ' - . 'WHERE `last_activity` < ?'; + . 'WHERE `last_activity` < ? ' + . 'AND `type` = ?'; $this->execute($sql, [ - $olderThan + $olderThan, + IToken::TEMPORARY_TOKEN, ]); } diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index b3564e0e81b..a4e44f3c5d2 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -61,14 +61,16 @@ class DefaultTokenProvider implements IProvider { * @param string $token * @param string $uid * @param string $password + * @apram int $type token type * @return DefaultToken */ - public function generateToken($token, $uid, $password, $name) { + public function generateToken($token, $uid, $password, $name, $type = IToken::TEMPORARY_TOKEN) { $dbToken = new DefaultToken(); $dbToken->setUid($uid); $dbToken->setPassword($this->encryptPassword($password, $token)); $dbToken->setName($name); $dbToken->setToken($this->hashToken($token)); + $dbToken->setType($type); $dbToken->setLastActivity(time()); $this->mapper->insert($dbToken); diff --git a/lib/private/Authentication/Token/IToken.php b/lib/private/Authentication/Token/IToken.php index 10b54c0d2a8..549a1f98268 100644 --- a/lib/private/Authentication/Token/IToken.php +++ b/lib/private/Authentication/Token/IToken.php @@ -27,6 +27,9 @@ namespace OC\Authentication\Token; */ interface IToken { + const TEMPORARY_TOKEN = 0; + const PERMANENT_TOKEN = 1; + /** * Get the token ID * |