Skip to content

Commit

Permalink
chore: Bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jul 5, 2024
1 parent 9046229 commit 86f2519
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 66 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2024 Ambroise Maupate
Copyright © 2023 Ambroise Maupate

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
22 changes: 8 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@
}
],
"type": "symfony-bundle",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"api-platform/core": "~3.2.14",
"roadiz/core-bundle": "2.3.*",
"symfony/framework-bundle": "6.4.*",
"symfony/rate-limiter": "6.4.*",
"symfony/lock": "6.4.*",
"doctrine/orm": "~2.19.0"
"api-platform/core": "~2.7.0",
"symfony/framework-bundle": "5.4.*",
"symfony/rate-limiter": "5.4.*",
"doctrine/orm": "~2.17.0"
},
"require-dev": {
"roadiz/core-bundle": "2.2.*",
"php-coveralls/php-coveralls": "^2.4",
"phpstan/phpstan": "^1.5.3",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan-doctrine": "^1.3",
"roadiz/entity-generator": "2.3.*",
"roadiz/doc-generator": "2.3.*",
"roadiz/random": "2.3.*",
"roadiz/jwt": "2.3.*"
"phpstan/phpstan-doctrine": "^1.3"
},
"config": {
"optimize-autoloader": true,
Expand All @@ -58,8 +52,8 @@
},
"extra": {
"branch-alias": {
"dev-main": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-main": "2.2.x-dev",
"dev-develop": "2.3.x-dev"
}
}
}
8 changes: 3 additions & 5 deletions config/api_resources/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ RZ\Roadiz\CoreBundle\Entity\User:
method: 'GET'
security: "is_granted('ROLE_ACCESS_USERS') or object == user"
normalizationContext:
groups: ['user', 'user_personal', 'user_security']
groups: ['user', 'user_security']
enable_max_depth: true

ApiPlatform\Metadata\GetCollection:
method: 'GET'
security: "is_granted('ROLE_ACCESS_USERS')"
normalizationContext:
groups: [ 'user', 'user_personal' ]
groups: [ 'user' ]
enable_max_depth: true

# Current user information operation MUST be declared AFTER ApiPlatform\Metadata\Get
Expand All @@ -106,11 +106,9 @@ RZ\Roadiz\CoreBundle\Entity\User:
class: ApiPlatform\Metadata\Get
# Path must be different from item operation to avoid conflict
uriTemplate: '/me'
itemUriTemplate: /users/{id}
provider: RZ\Roadiz\UserBundle\State\UserTokenProvider
output: RZ\Roadiz\UserBundle\Api\Dto\UserOutput
normalizationContext:
groups: ['user', 'user_personal', 'user_security']
enable_max_depth: true
openapiContext:
summary: Get current user (JWT) information
description: |
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
parameters:
level: 7
level: 5
paths:
- src
excludePaths:
- */node_modules/*
- */bower_components/*
- */static/*
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Call to an undefined method RZ\\Roadiz\\CoreBundle\\Repository#'
- '#Call to an undefined method RZ\\Roadiz\\UserBundle\\Repository#'
- '#Call to an undefined method Doctrine\\Persistence\\ObjectRepository#'
Expand All @@ -32,6 +30,8 @@ parameters:
- '#does not accept Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'

reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
doctrine:
repositoryClass: RZ\Roadiz\CoreBundle\Repository\EntityRepository
includes:
Expand Down
19 changes: 1 addition & 18 deletions src/Api/Dto/UserOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,21 @@

namespace RZ\Roadiz\UserBundle\Api\Dto;

use ApiPlatform\Metadata\ApiResource;
use Symfony\Component\Serializer\Attribute\Groups;
use ApiPlatform\Metadata\ApiProperty;

#[ApiResource(
operations: [],
)]
final class UserOutput
{
#[Groups(['user'])]
public string $identifier = '';
#[Groups(['user'])]
public array $roles = [];
#[Groups(['user'])]
public ?string $firstName = null;
#[Groups(['user'])]
public ?string $publicName = null;
#[Groups(['user'])]
public ?string $lastName = null;
#[Groups(['user'])]
public ?string $phone = null;
#[Groups(['user'])]
public ?string $company = null;
#[Groups(['user'])]
public ?string $locale = null;
#[Groups(['user'])]
public ?string $pictureUrl = null;
#[Groups(['user'])]
public ?array $metadata = null;
#[Groups(['user'])]
public ?string $job = null;
#[Groups(['user'])]
public ?\DateTime $birthday = null;
#[Groups(['user'])]
public bool $emailValidated = false;
}
5 changes: 4 additions & 1 deletion src/Console/PurgeUserValidationTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

final class PurgeUserValidationTokenCommand extends Command
{
public function __construct(private readonly ManagerRegistry $managerRegistry, string $name = null)
private ManagerRegistry $managerRegistry;

public function __construct(ManagerRegistry $managerRegistry, string $name = null)
{
parent::__construct($name);
$this->managerRegistry = $managerRegistry;
}

protected function configure(): void
Expand Down
1 change: 1 addition & 0 deletions src/Entity/UserValidationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace RZ\Roadiz\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use RZ\Roadiz\CoreBundle\Entity\User;
use RZ\Roadiz\UserBundle\Repository\UserValidationTokenRepository;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down
5 changes: 4 additions & 1 deletion src/EventSubscriber/UserSignedUpSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

final class UserSignedUpSubscriber implements EventSubscriberInterface
{
private UserValidationTokenManagerInterface $userValidationTokenManager;

public function __construct(
private readonly UserValidationTokenManagerInterface $userValidationTokenManager
UserValidationTokenManagerInterface $userValidationTokenManager
) {
$this->userValidationTokenManager = $userValidationTokenManager;
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/Manager/UserMetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

class UserMetadataManager implements UserMetadataManagerInterface
{
public function __construct(private readonly ManagerRegistry $managerRegistry)
private ManagerRegistry $managerRegistry;

/**
* @param ManagerRegistry $managerRegistry
*/
public function __construct(ManagerRegistry $managerRegistry)
{
$this->managerRegistry = $managerRegistry;
}

public function getMetadataForUser(User $user): ?UserMetadata
Expand Down
41 changes: 31 additions & 10 deletions src/Manager/UserValidationTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,39 @@

final class UserValidationTokenManager implements UserValidationTokenManagerInterface
{
private ManagerRegistry $managerRegistry;
private UrlGeneratorInterface $urlGenerator;
private TranslatorInterface $translator;
private LoggerInterface $logger;
private EmailManager $emailManager;
private Settings $settingsBag;
private RoleHierarchyInterface $roleHierarchy;
private string $emailValidatedRoleName;
private int $userValidationExpiresIn;
private string $userValidationUrl;

public function __construct(
private readonly ManagerRegistry $managerRegistry,
private readonly UrlGeneratorInterface $urlGenerator,
private readonly TranslatorInterface $translator,
private readonly LoggerInterface $logger,
private readonly EmailManager $emailManager,
private readonly Settings $settingsBag,
private readonly RoleHierarchyInterface $roleHierarchy,
private readonly string $emailValidatedRoleName,
private readonly int $userValidationExpiresIn,
private readonly string $userValidationUrl
ManagerRegistry $managerRegistry,
UrlGeneratorInterface $urlGenerator,
TranslatorInterface $translator,
LoggerInterface $logger,
EmailManager $emailManager,
Settings $settingsBag,
RoleHierarchyInterface $roleHierarchy,
string $emailValidatedRoleName,
int $userValidationExpiresIn,
string $userValidationUrl
) {
$this->managerRegistry = $managerRegistry;
$this->logger = $logger;
$this->userValidationExpiresIn = $userValidationExpiresIn;
$this->emailManager = $emailManager;
$this->userValidationUrl = $userValidationUrl;
$this->settingsBag = $settingsBag;
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;
$this->roleHierarchy = $roleHierarchy;
$this->emailValidatedRoleName = $emailValidatedRoleName;
}

public function createForUser(UserInterface $user): UserValidationToken
Expand Down
2 changes: 1 addition & 1 deletion src/State/UserPasswordRequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getRecaptchaHeaderName(): string
return $this->recaptchaHeaderName;
}

public function process($data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
{
if (!$data instanceof UserPasswordRequestInput) {
throw new \RuntimeException(sprintf('Cannot process %s', get_class($data)));
Expand Down
2 changes: 1 addition & 1 deletion src/State/UserPasswordResetProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
) {
}

public function process($data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
{
if (!$data instanceof UserPasswordTokenInput) {
throw new \RuntimeException(sprintf('Cannot process %s', get_class($data)));
Expand Down
4 changes: 2 additions & 2 deletions src/State/UserSignupProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

final class UserSignupProcessor implements ProcessorInterface
Expand Down Expand Up @@ -51,7 +51,7 @@ protected function getRecaptchaHeaderName(): string
return $this->recaptchaHeaderName;
}

public function process($data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
{
if (!$data instanceof UserInput) {
throw new BadRequestHttpException(sprintf('Cannot process %s', get_class($data)));
Expand Down
8 changes: 4 additions & 4 deletions src/State/UserTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
use RZ\Roadiz\UserBundle\Manager\UserMetadataManagerInterface;
use RZ\Roadiz\UserBundle\Manager\UserValidationTokenManagerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;

final class UserTokenProvider implements ProviderInterface
{
public function __construct(
private readonly Security $security,
private readonly UserValidationTokenManagerInterface $userValidationTokenManager,
private readonly UserMetadataManagerInterface $userMetadataManager,
private Security $security,
private UserValidationTokenManagerInterface $userValidationTokenManager,
private UserMetadataManagerInterface $userMetadataManager,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/State/UserValidationRequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use RZ\Roadiz\UserBundle\Manager\UserValidationTokenManagerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Security;

final class UserValidationRequestProcessor implements ProcessorInterface
{
Expand All @@ -27,7 +27,7 @@ public function __construct(
) {
}

public function process($data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
{
if (!$data instanceof UserValidationRequestInput) {
throw new \RuntimeException(sprintf('Cannot process %s', get_class($data)));
Expand Down
4 changes: 2 additions & 2 deletions src/State/UserValidationTokenProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use RZ\Roadiz\UserBundle\Event\UserEmailValidated;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

final class UserValidationTokenProcessor implements ProcessorInterface
Expand All @@ -29,7 +29,7 @@ public function __construct(
) {
}

public function process($data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): VoidOutput
{
if (!$data instanceof UserValidationTokenInput) {
throw new \RuntimeException(sprintf('Cannot process %s', get_class($data)));
Expand Down

0 comments on commit 86f2519

Please sign in to comment.