@@ 72-87 (lines=16) @@ | ||
69 | * |
|
70 | * @throws DoesNotExistException |
|
71 | */ |
|
72 | public function getToken(string $token): PublicKeyToken { |
|
73 | /* @var $qb IQueryBuilder */ |
|
74 | $qb = $this->db->getQueryBuilder(); |
|
75 | $result = $qb->select('*') |
|
76 | ->from('authtoken') |
|
77 | ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
78 | ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
79 | ->execute(); |
|
80 | ||
81 | $data = $result->fetch(); |
|
82 | $result->closeCursor(); |
|
83 | if ($data === false) { |
|
84 | throw new DoesNotExistException('token does not exist'); |
|
85 | } |
|
86 | return PublicKeyToken::fromRow($data); |
|
87 | } |
|
88 | ||
89 | /** |
|
90 | * Get the token for $id |
|
@@ 94-109 (lines=16) @@ | ||
91 | * |
|
92 | * @throws DoesNotExistException |
|
93 | */ |
|
94 | public function getTokenById(int $id): PublicKeyToken { |
|
95 | /* @var $qb IQueryBuilder */ |
|
96 | $qb = $this->db->getQueryBuilder(); |
|
97 | $result = $qb->select('*') |
|
98 | ->from('authtoken') |
|
99 | ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
100 | ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
101 | ->execute(); |
|
102 | ||
103 | $data = $result->fetch(); |
|
104 | $result->closeCursor(); |
|
105 | if ($data === false) { |
|
106 | throw new DoesNotExistException('token does not exist'); |
|
107 | } |
|
108 | return PublicKeyToken::fromRow($data); |
|
109 | } |
|
110 | ||
111 | /** |
|
112 | * Get all tokens of a user |