|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2022 SURFnet bv |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service; |
|
20
|
|
|
|
|
21
|
|
|
use Pagerfanta\Pagerfanta; |
|
22
|
|
|
use Surfnet\Stepup\Identity\Value\RecoveryTokenId; |
|
23
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Exception\NotFoundException; |
|
24
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity; |
|
25
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RecoveryToken; |
|
26
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RecoveryTokenQuery; |
|
27
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RecoveryTokenRepository; |
|
28
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RecoveryTokenStatus; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** @extends AbstractSearchService<RecoveryToken> */ |
|
31
|
|
|
class RecoveryTokenService extends AbstractSearchService |
|
32
|
|
|
{ |
|
33
|
|
|
public function __construct(private readonly RecoveryTokenRepository $recoveryTokenRepository) |
|
34
|
|
|
{ |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return Pagerfanta<RecoveryToken> |
|
39
|
|
|
*/ |
|
40
|
|
|
public function search(RecoveryTokenQuery $query): Pagerfanta |
|
41
|
|
|
{ |
|
42
|
|
|
$doctrineQuery = $this->recoveryTokenRepository->createSearchQuery($query); |
|
43
|
|
|
|
|
44
|
|
|
return $this->createPaginatorFrom($doctrineQuery, $query); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function get(RecoveryTokenId $id): RecoveryToken |
|
48
|
|
|
{ |
|
49
|
|
|
$recoveryToken = $this->recoveryTokenRepository->find($id); |
|
50
|
|
|
if (!$recoveryToken) { |
|
51
|
|
|
throw new NotFoundException(sprintf('Unable to find Recovery Token with id %s', $id)); |
|
52
|
|
|
} |
|
53
|
|
|
return $recoveryToken; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getFilterOptions(RecoveryTokenQuery $query): array |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->getFilteredQueryOptions($this->recoveryTokenRepository->createOptionsQuery($query)); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function identityHasActiveRecoveryToken(Identity $identity): bool |
|
62
|
|
|
{ |
|
63
|
|
|
$recoveryTokens = $this->recoveryTokenRepository->findBy( |
|
64
|
|
|
[ |
|
65
|
|
|
'identityId' => $identity->id, |
|
66
|
|
|
'status' => RecoveryTokenStatus::active(), |
|
67
|
|
|
], |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
|
|
return $recoveryTokens !== []; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths