-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Azure authenticator + External auth list
- fixed Azure authenticator - fixed Doctrine mapping - added the list of external authentication on the user edit page
- Loading branch information
Showing
18 changed files
with
217 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Infrastructure/User/Doctrine/ReadModel/FindExternalAuthenticationsQueryHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Infrastructure\User\Doctrine\ReadModel; | ||
|
||
use App\ReadModel\User\ExternalAuthView; | ||
use App\ReadModel\User\FindExternalAuthenticationsQuery; | ||
use DateTimeImmutable; | ||
use DateTimeZone; | ||
use Doctrine\DBAL\Connection; | ||
use Exception; | ||
use SixtyEightPublishers\ArchitectureBundle\ReadModel\Query\QueryHandlerInterface; | ||
|
||
final class FindExternalAuthenticationsQueryHandler implements QueryHandlerInterface | ||
{ | ||
public function __construct( | ||
private readonly Connection $connection, | ||
) {} | ||
|
||
/** | ||
* @return array<int, ExternalAuthView> | ||
* @throws Exception | ||
*/ | ||
public function __invoke(FindExternalAuthenticationsQuery $query): array | ||
{ | ||
$rows = $this->connection->createQueryBuilder() | ||
->select('uea.user_id, uea.provider_code, uea.created_at, uea.resource_owner_id') | ||
->from('user_external_auth', 'uea') | ||
->join('uea', '"user"', 'u', 'u.id = uea.user_id AND u.deleted_at IS NULL') | ||
->where('uea.user_id = :userId') | ||
->orderBy('uea.created_at', 'DESC') | ||
->setParameters([ | ||
'userId' => $query->userId(), | ||
]) | ||
->fetchAllAssociative(); | ||
|
||
$result = []; | ||
|
||
foreach ($rows as $row) { | ||
$result[] = new ExternalAuthView( | ||
userId: $row['user_id'], | ||
providerCode: $row['provider_code'], | ||
createdAt: new DateTimeImmutable($row['created_at'], new DateTimeZone('UTC')), | ||
resourceOwnerId: $row['resource_owner_id'], | ||
); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ReadModel\User; | ||
|
||
use DateTimeImmutable; | ||
|
||
final class ExternalAuthView | ||
{ | ||
public function __construct( | ||
public readonly string $userId, | ||
public readonly string $providerCode, | ||
public readonly ?DateTimeImmutable $createdAt, | ||
public readonly string $resourceOwnerId, | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ReadModel\User; | ||
|
||
use SixtyEightPublishers\ArchitectureBundle\ReadModel\Query\AbstractQuery; | ||
|
||
final class FindExternalAuthenticationsQuery extends AbstractQuery | ||
{ | ||
public static function create(string $userId): self | ||
{ | ||
return self::fromParameters([ | ||
'user_id' => $userId, | ||
]); | ||
} | ||
|
||
public function userId(): string | ||
{ | ||
return $this->getParam('user_id'); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Web/AdminModule/UserModule/Control/ExternalAuthList/ExternalAuthListControl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Web\AdminModule\UserModule\Control\ExternalAuthList; | ||
|
||
use App\ReadModel\User\FindExternalAuthenticationsQuery; | ||
use App\Web\Ui\Control; | ||
use SixtyEightPublishers\ArchitectureBundle\Bus\QueryBusInterface; | ||
|
||
final class ExternalAuthListControl extends Control | ||
{ | ||
public function __construct( | ||
private readonly string $userId, | ||
private readonly QueryBusInterface $queryBus, | ||
) {} | ||
|
||
protected function beforeRender(): void | ||
{ | ||
parent::beforeRender(); | ||
|
||
$template = $this->getTemplate(); | ||
assert($template instanceof ExternalAuthListTemplate); | ||
|
||
$template->externalAuths = $this->queryBus->dispatch(FindExternalAuthenticationsQuery::create( | ||
userId: $this->userId, | ||
)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...minModule/UserModule/Control/ExternalAuthList/ExternalAuthListControlFactoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Web\AdminModule\UserModule\Control\ExternalAuthList; | ||
|
||
interface ExternalAuthListControlFactoryInterface | ||
{ | ||
public function create(string $userId): ExternalAuthListControl; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Web/AdminModule/UserModule/Control/ExternalAuthList/ExternalAuthListTemplate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Web\AdminModule\UserModule\Control\ExternalAuthList; | ||
|
||
use App\ReadModel\User\ExternalAuthView; | ||
use Nette\Bridges\ApplicationLatte\Template; | ||
|
||
final class ExternalAuthListTemplate extends Template | ||
{ | ||
/** @var array<int, ExternalAuthView> */ | ||
public array $externalAuths; | ||
} |
26 changes: 26 additions & 0 deletions
26
...b/AdminModule/UserModule/Control/ExternalAuthList/templates/externalAuthListControl.latte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{templateType App\Web\AdminModule\UserModule\Control\ExternalAuthList\ExternalAuthListTemplate} | ||
|
||
<div class="px-4 sm:px-6 lg:px-8 py-4"> | ||
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | ||
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8"> | ||
<table class="min-w-full divide-y divide-gray-300"> | ||
<thead> | ||
<tr> | ||
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-0">{_auth_type}</th> | ||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">{_resource_owner_id}</th> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody class="divide-y divide-gray-200"> | ||
<tr n:foreach="$externalAuths as $externalAuth"> | ||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm text-gray-500 sm:pl-0">{$externalAuth->providerCode}</td> | ||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{$externalAuth->resourceOwnerId}</td> | ||
</tr> | ||
<tr n:if="0 >= count($externalAuths)"> | ||
<td colspan="2" class="whitespace-nowrap py-4 pl-4 pr-3 text-sm text-gray-500 sm:pl-0">{_no_rows}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...s/App_Web_AdminModule_UserModule_Control_ExternalAuthList_ExternalAuthListControl.cs.neon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
auth_type: Typ autentizace | ||
resource_owner_id: ID uživatele | ||
no_rows: Uživatel nepoužívá žádnou externí autentizaci. |
3 changes: 3 additions & 0 deletions
3
...s/App_Web_AdminModule_UserModule_Control_ExternalAuthList_ExternalAuthListControl.en.neon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
auth_type: Authentication type | ||
resource_owner_id: User ID | ||
no_rows: The user does not use any external authentication. |
1 change: 1 addition & 0 deletions
1
translations/App_Web_AdminModule_UserModule_Presenter_EditUserPresenter.cs.neon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
translations/App_Web_AdminModule_UserModule_Presenter_EditUserPresenter.en.neon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters