Skip to content

Commit 460b298

Browse files
OXDEV-9919 Refactor oauth providers and services
1 parent fe83485 commit 460b298

46 files changed

Lines changed: 845 additions & 529 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Authentication/OAuth2/Controller/OAuthController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
38
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Controller;
49

510
use OxidEsales\Eshop\Application\Controller\FrontendController;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\DTO;
11+
12+
readonly class OAuth2UserDTO implements OAuth2UserDTOInterface
13+
{
14+
public function __construct(
15+
private ?string $firstName,
16+
private ?string $lastName,
17+
private ?string $email,
18+
) {
19+
}
20+
21+
public function getFirstName(): ?string
22+
{
23+
return $this->firstName;
24+
}
25+
26+
public function getLastName(): ?string
27+
{
28+
return $this->lastName;
29+
}
30+
31+
public function getEmail(): ?string
32+
{
33+
return $this->email;
34+
}
35+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\DTO;
9+
10+
interface OAuth2UserDTOInterface
11+
{
12+
public function getFirstName(): ?string;
13+
14+
public function getLastName(): ?string;
15+
16+
public function getEmail(): ?string;
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\DTO;
11+
12+
class UserDTO implements UserDTOInterface
13+
{
14+
public function __construct(
15+
private readonly string $userId,
16+
private readonly bool $isBlocked
17+
) {
18+
}
19+
20+
public function getId(): string
21+
{
22+
return $this->userId;
23+
}
24+
25+
public function isBlocked(): bool
26+
{
27+
return $this->isBlocked;
28+
}
29+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\DTO;
9+
10+
interface UserDTOInterface
11+
{
12+
public function getId(): string;
13+
14+
public function isBlocked(): bool;
15+
}

src/Authentication/OAuth2/DataObject/User.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Authentication/OAuth2/DataObject/UserInterface.php

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Infrastructure\Factory;
11+
12+
use OxidEsales\Eshop\Application\Model\User as UserModel;
13+
use OxidEsales\SecurityModule\Authentication\OAuth2\DTO\UserDTO;
14+
use OxidEsales\SecurityModule\Authentication\OAuth2\DTO\UserDTOInterface;
15+
16+
class UserDTOFactory implements UserDTOFactoryInterface
17+
{
18+
public function createFromModel(UserModel $userModel): UserDTOInterface
19+
{
20+
return new UserDTO(
21+
$userModel->getId(),
22+
$userModel->inGroup('oxidblocked'),
23+
);
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Infrastructure\Factory;
9+
10+
use OxidEsales\Eshop\Application\Model\User as UserModel;
11+
use OxidEsales\SecurityModule\Authentication\OAuth2\DTO\UserDTOInterface;
12+
13+
interface UserDTOFactoryInterface
14+
{
15+
public function createFromModel(UserModel $userModel): UserDTOInterface;
16+
}

src/Authentication/OAuth2/Infrastructure/UserFactory.php renamed to src/Authentication/OAuth2/Infrastructure/Factory/UserFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
declare(strict_types=1);
99

10-
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Infrastructure;
10+
namespace OxidEsales\SecurityModule\Authentication\OAuth2\Infrastructure\Factory;
1111

1212
use OxidEsales\Eshop\Application\Model\User;
1313

0 commit comments

Comments
 (0)