Browse Source
Fixes from static analysis
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: Lucas Azevedo <lhs_azevedo@hotmail.com>
pull/40026/head
Lucas Azevedo
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
6 additions and
6 deletions
-
core/Command/User/AuthTokens/Delete.php
-
lib/private/Authentication/Token/PublicKeyTokenMapper.php
|
|
|
@ -63,7 +63,7 @@ class Delete extends Base { |
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int { |
|
|
|
$uid = $input->getArgument('uid'); |
|
|
|
$id = $input->getArgument('id'); |
|
|
|
$id = (int) $input->getArgument('id'); |
|
|
|
$before = $input->getOption('last-used-before'); |
|
|
|
|
|
|
|
if ($before) { |
|
|
|
@ -80,13 +80,13 @@ class Delete extends Base { |
|
|
|
return $this->deleteById($uid, $id); |
|
|
|
} |
|
|
|
|
|
|
|
protected function deleteById(string $uid, string $id) { |
|
|
|
protected function deleteById(string $uid, int $id): int { |
|
|
|
$this->tokenProvider->invalidateTokenById($uid, $id); |
|
|
|
|
|
|
|
return Command::SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
protected function deleteLastUsedBefore(string $uid, string $before) { |
|
|
|
protected function deleteLastUsedBefore(string $uid, string $before): int { |
|
|
|
$date = $this->parseDateOption($before); |
|
|
|
if (!$date) { |
|
|
|
throw new RuntimeException('Invalid date format. Acceptable formats are: ISO8601 (w/o fractions), "YYYY-MM-DD" and Unix time in seconds.'); |
|
|
|
|
|
|
|
@ -71,11 +71,11 @@ class PublicKeyTokenMapper extends QBMapper { |
|
|
|
|
|
|
|
public function invalidateLastUsedBefore(string $uid, int $before): int { |
|
|
|
$qb = $this->db->getQueryBuilder(); |
|
|
|
return $qb->delete($this->tableName) |
|
|
|
$qb->delete($this->tableName) |
|
|
|
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
|
|
->andWhere($qb->expr()->lt('last_activity', $qb->createNamedParameter($before, IQueryBuilder::PARAM_INT))) |
|
|
|
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
|
|
->executeStatement(); |
|
|
|
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
|
|
return $query->executeStatement(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|