@@ -13,12 +13,12 @@ |
||
13 | 13 | |
14 | 14 | class Provider extends AProvider { |
15 | 15 | |
16 | - #[\Override] |
|
16 | + #[\Override ] |
|
17 | 17 | public function getDisplayName(): string { |
18 | 18 | return $this->l10n->t('Telegram verification'); |
19 | 19 | } |
20 | 20 | |
21 | - #[\Override] |
|
21 | + #[\Override ] |
|
22 | 22 | public function getDescription(): string { |
23 | 23 | return $this->l10n->t('Authenticate via Telegram'); |
24 | 24 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | return $this->verificationCode; |
83 | 83 | } |
84 | 84 | |
85 | - #[\Override] |
|
85 | + #[\Override ] |
|
86 | 86 | public function jsonSerialize(): mixed { |
87 | 87 | return [ |
88 | 88 | 'gatewayName' => $this->gatewayName, |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * SPDX-FileCopyrightText: 2024 Christoph Wurst <[email protected]> |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | parent::__construct('twofactorauth:gateway:status'); |
23 | 23 | } |
24 | 24 | |
25 | - #[\Override] |
|
25 | + #[\Override ] |
|
26 | 26 | protected function execute(InputInterface $input, OutputInterface $output) { |
27 | 27 | $fqcn = $this->gatewayFactory->getFqcnList(); |
28 | 28 | foreach ($fqcn as $fqcn) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $gateway = $this->gatewayFactory->get($fqcn::getProviderId()); |
31 | 31 | $isConfigured = $gateway->isComplete(); |
32 | 32 | $settings = $gateway->getSettings(); |
33 | - $output->writeln($settings['name'] . ': ' . ($isConfigured ? 'configured' : 'not configured')); |
|
33 | + $output->writeln($settings[ 'name' ].': '.($isConfigured ? 'configured' : 'not configured')); |
|
34 | 34 | } |
35 | 35 | return 0; |
36 | 36 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Symfony\Component\Console\Question\ChoiceQuestion; |
21 | 21 | |
22 | 22 | class Remove extends Command { |
23 | - private array $ids = []; |
|
23 | + private array $ids = [ ]; |
|
24 | 24 | |
25 | 25 | public function __construct( |
26 | 26 | private Factory $gatewayFactory, |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | $fqcn = $this->gatewayFactory->getFqcnList(); |
31 | 31 | foreach ($fqcn as $fqcn) { |
32 | - $this->ids[] = $fqcn::getProviderId(); |
|
32 | + $this->ids[ ] = $fqcn::getProviderId(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $this->addArgument( |
36 | 36 | 'gateway', |
37 | 37 | InputArgument::OPTIONAL, |
38 | - 'The name of the gateway: ' . implode(', ', $this->ids) |
|
38 | + 'The name of the gateway: '.implode(', ', $this->ids) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
42 | - #[\Override] |
|
42 | + #[\Override ] |
|
43 | 43 | protected function execute(InputInterface $input, OutputInterface $output) { |
44 | 44 | $gatewayName = strtolower((string)$input->getArgument('gateway')); |
45 | 45 | if (!in_array($gatewayName, $this->ids, true)) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** @var AGateway */ |
53 | 53 | $gateway = $this->gatewayFactory->get($gatewayName); |
54 | 54 | } catch (Exception $e) { |
55 | - $output->writeln('<error>' . $e->getMessage() . '</error>'); |
|
55 | + $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
56 | 56 | return 1; |
57 | 57 | } |
58 | 58 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Symfony\Component\Console\Question\ChoiceQuestion; |
21 | 21 | |
22 | 22 | class Configure extends Command { |
23 | - private array $ids = []; |
|
23 | + private array $ids = [ ]; |
|
24 | 24 | |
25 | 25 | public function __construct( |
26 | 26 | private Factory $gatewayFactory, |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | $fqcn = $this->gatewayFactory->getFqcnList(); |
31 | 31 | foreach ($fqcn as $fqcn) { |
32 | - $this->ids[] = $fqcn::getProviderId(); |
|
32 | + $this->ids[ ] = $fqcn::getProviderId(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $this->addArgument( |
36 | 36 | 'gateway', |
37 | 37 | InputArgument::OPTIONAL, |
38 | - 'The name of the gateway: ' . implode(', ', $this->ids) |
|
38 | + 'The name of the gateway: '.implode(', ', $this->ids) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
42 | - #[\Override] |
|
42 | + #[\Override ] |
|
43 | 43 | protected function execute(InputInterface $input, OutputInterface $output) { |
44 | 44 | $gatewayName = strtolower((string)$input->getArgument('gateway')); |
45 | 45 | if (!in_array($gatewayName, $this->ids, true)) { |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | * 400: User not found |
44 | 44 | * 503: Gateway wasn't configured yed |
45 | 45 | */ |
46 | - #[NoAdminRequired] |
|
47 | - #[ApiRoute(verb: 'GET', url: '/settings/{gateway}/verification')] |
|
46 | + #[NoAdminRequired ] |
|
47 | + #[ApiRoute(verb: 'GET', url: '/settings/{gateway}/verification') ] |
|
48 | 48 | public function getVerificationState(string $gateway): JSONResponse { |
49 | 49 | $user = $this->userSession->getUser(); |
50 | 50 | |
51 | 51 | if (is_null($user)) { |
52 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
52 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if (!$this->gatewayFactory->get($gateway)->isComplete()) { |
56 | - return new JSONResponse([], Http::STATUS_SERVICE_UNAVAILABLE); |
|
56 | + return new JSONResponse([ ], Http::STATUS_SERVICE_UNAVAILABLE); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return new JSONResponse($this->setup->getState($user, $gateway)->jsonSerialize()); |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | * 200: OK |
71 | 71 | * 400: User not found |
72 | 72 | */ |
73 | - #[NoAdminRequired] |
|
74 | - #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/start')] |
|
73 | + #[NoAdminRequired ] |
|
74 | + #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/start') ] |
|
75 | 75 | public function startVerification(string $gateway, string $identifier): JSONResponse { |
76 | 76 | $user = $this->userSession->getUser(); |
77 | 77 | |
78 | 78 | if (is_null($user)) { |
79 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
79 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | try { |
83 | 83 | $state = $this->setup->startSetup($user, $gateway, $identifier); |
84 | 84 | } catch (VerificationException $e) { |
85 | - return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
85 | + return new JSONResponse([ 'message' => $e->getMessage() ], Http::STATUS_BAD_REQUEST); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return new JSONResponse([ |
@@ -101,22 +101,22 @@ discard block |
||
101 | 101 | * 200: OK |
102 | 102 | * 400: User not found |
103 | 103 | */ |
104 | - #[NoAdminRequired] |
|
105 | - #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/finish')] |
|
104 | + #[NoAdminRequired ] |
|
105 | + #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/finish') ] |
|
106 | 106 | public function finishVerification(string $gateway, string $verificationCode): JSONResponse { |
107 | 107 | $user = $this->userSession->getUser(); |
108 | 108 | |
109 | 109 | if (is_null($user)) { |
110 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
110 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | try { |
114 | 114 | $this->setup->finishSetup($user, $gateway, $verificationCode); |
115 | 115 | } catch (VerificationException) { |
116 | - return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
116 | + return new JSONResponse([ ], Http::STATUS_BAD_REQUEST); |
|
117 | 117 | } |
118 | 118 | |
119 | - return new JSONResponse([]); |
|
119 | + return new JSONResponse([ ]); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * 200: OK |
129 | 129 | * 400: User not found |
130 | 130 | */ |
131 | - #[NoAdminRequired] |
|
132 | - #[ApiRoute(verb: 'DELETE', url: '/settings/{gateway}/verification')] |
|
131 | + #[NoAdminRequired ] |
|
132 | + #[ApiRoute(verb: 'DELETE', url: '/settings/{gateway}/verification') ] |
|
133 | 133 | public function revokeVerification(string $gateway): JSONResponse { |
134 | 134 | $user = $this->userSession->getUser(); |
135 | 135 | |
136 | 136 | if (is_null($user)) { |
137 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
137 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return new JSONResponse($this->setup->disable($user, $gateway)); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | ) { |
23 | 23 | } |
24 | 24 | |
25 | - #[\Override] |
|
25 | + #[\Override ] |
|
26 | 26 | public function getBody(): ITemplate { |
27 | 27 | $template = Server::get(ITemplateManager::class)->getTemplate('twofactor_gateway', 'personal_settings'); |
28 | 28 | $template->assign('gateway', $this->gateway); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | private function buildConfigKey(string $gatewayName, string $key): string { |
30 | - return $gatewayName . "_$key"; |
|
30 | + return $gatewayName."_$key"; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | private function getUserValue(IUser $user, string $gatewayName, string $key, string $default = ''): string { |