Skip to content

Commit 29d0fee

Browse files
committed
89 - Allow string url for verify action
1 parent 03907b6 commit 29d0fee

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

src/Authentication/TwoFactorProcessor/OneTimePasswordProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public function proceed(ServerRequestInterface $request, ResultInterface $result
9292
* Generates 2fa url, if enable.
9393
*
9494
* @param string $type Processor type.
95-
* @return array|null
95+
* @return array|string|null
9696
*/
97-
public function getUrlByType(string $type): ?array
97+
public function getUrlByType(string $type): array|string|null
9898
{
9999
if ($type == $this->getType()) {
100100
return Configure::read('OneTimePasswordAuthenticator.verifyAction');

src/Authentication/TwoFactorProcessor/Webauthn2faProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public function proceed(ServerRequestInterface $request, ResultInterface $result
9292
* Generates 2fa url, if enable.
9393
*
9494
* @param string $type Processor type.
95-
* @return array|null
95+
* @return array|string|null
9696
*/
97-
public function getUrlByType(string $type): ?array
97+
public function getUrlByType(string $type): array|string|null
9898
{
9999
if ($type == $this->getType()) {
100100
return Configure::read('Webauthn2fa.startAction');

src/Authentication/TwoFactorProcessorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function proceed(ServerRequestInterface $request, ResultInterface $result
4747
* Generates 2fa url, if enable.
4848
*
4949
* @param string $type Processor type.
50-
* @return array|null
50+
* @return array|string|null
5151
*/
52-
public function getUrlByType(string $type): ?array;
52+
public function getUrlByType(string $type): array|string|null;
5353
}

src/Middleware/TwoFactorMiddleware.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
5252
$session->write(CookieAuthenticator::SESSION_DATA_KEY, [
5353
'remember_me' => $data['remember_me'] ?? null,
5454
]);
55-
$url = array_merge($url, [
56-
'?' => $request->getQueryParams(),
57-
]);
55+
$params = $request->getQueryParams();
56+
if (is_array($url)) {
57+
$url = array_merge($url, [
58+
'?' => $params,
59+
]);
60+
} else {
61+
$url .= '?' . implode('&', array_map(fn ($k, $v) => "$k=$v", array_keys($params), array_values($params)));
62+
}
63+
5864
$url = Router::url($url);
5965

6066
return (new Response())

0 commit comments

Comments
 (0)