summaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-05-12 16:14:32 +0200
committerLukas Reschke <lukas@statuscode.ch>2017-05-18 20:49:07 +0200
commit1eb7f4956b1cdc99d0345600047cd6137051790f (patch)
tree3fe53d6f59f0b4db344c3336c8355ade038bc34a /lib/private/Authentication
parent23b296b66eaf674d8eac4b00b044c1dfeda53014 (diff)
downloadnextcloud-server-1eb7f4956b1cdc99d0345600047cd6137051790f.tar.gz
nextcloud-server-1eb7f4956b1cdc99d0345600047cd6137051790f.zip
delete auth token when client gets deleted
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Authentication')
-rw-r--r--lib/private/Authentication/Token/DefaultTokenMapper.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenMapper.php b/lib/private/Authentication/Token/DefaultTokenMapper.php
index 8848cd3ec56..a69e9e940cd 100644
--- a/lib/private/Authentication/Token/DefaultTokenMapper.php
+++ b/lib/private/Authentication/Token/DefaultTokenMapper.php
@@ -31,7 +31,7 @@ use OCP\IUser;
class DefaultTokenMapper extends Mapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'authtoken');
+ parent::__construct($db, 'AuthToken');
}
/**
@@ -42,7 +42,7 @@ class DefaultTokenMapper extends Mapper {
public function invalidate($token) {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
- $qb->delete('authtoken')
+ $qb->delete('AuthToken')
->where($qb->expr()->eq('token', $qb->createParameter('token')))
->setParameter('token', $token)
->execute();
@@ -55,7 +55,7 @@ class DefaultTokenMapper extends Mapper {
public function invalidateOld($olderThan, $remember = IToken::DO_NOT_REMEMBER) {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
- $qb->delete('authtoken')
+ $qb->delete('AuthToken')
->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT)))
@@ -73,7 +73,7 @@ class DefaultTokenMapper extends Mapper {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'remember', 'token', 'last_activity', 'last_check', 'scope')
- ->from('authtoken')
+ ->from('AuthToken')
->where($qb->expr()->eq('token', $qb->createNamedParameter($token)))
->execute();
@@ -97,7 +97,7 @@ class DefaultTokenMapper extends Mapper {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'token', 'last_activity', 'last_check', 'scope')
- ->from('authtoken')
+ ->from('AuthToken')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->execute();
@@ -122,7 +122,7 @@ class DefaultTokenMapper extends Mapper {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'remember', 'token', 'last_activity', 'last_check', 'scope')
- ->from('authtoken')
+ ->from('AuthToken')
->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
->setMaxResults(1000);
$result = $qb->execute();
@@ -143,10 +143,22 @@ class DefaultTokenMapper extends Mapper {
public function deleteById(IUser $user, $id) {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
- $qb->delete('authtoken')
+ $qb->delete('AuthToken')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())));
$qb->execute();
}
+ /**
+ * delete all auth token which belong to a specific client if the client was deleted
+ *
+ * @param string $name
+ */
+ public function deleteByName($name) {
+ $qb = $this->db->getQueryBuilder();
+ $qb->delete('AuthToken')
+ ->where($qb->expr()->eq('name', $qb->createNamedParameter($name)));
+ $qb->execute();
+ }
+
}