Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 45 additions & 56 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "connectholland/user-bundle",
"type": "symfony-bundle",
"description": "User bundle for Symfony 4 projects",
"description": "User bundle for Symfony 6/7 projects",
"license": "MIT",
"authors": [
{
Expand All @@ -10,60 +10,54 @@
}
],
"require": {
"php": "^7.3",
"php": "^8.1",
"ext-json": "*",
"doctrine/collections": "^1.6",
"doctrine/doctrine-bundle": "^1.11 || ^2.0",
"doctrine/orm": "^2.6",
"doctrine/persistence": "^1.1 || ^2.0",
"gisostallenberg/response-content-negotiation-bundle": "^0.9",
"haydenpierce/class-finder": "^0.4.0",
"league/html-to-markdown": "^4.8",
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
"php-http/httplug-bundle": "^1.16",
"rollerworks/password-strength-validator": "^1.2",
"sensio/framework-extra-bundle": "^5.5",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/config": "^4.4 || ^5.0",
"symfony/console": "^4.4 || ^5.0",
"symfony/css-selector": "^5.2",
"symfony/dependency-injection": "^4.4 || ^5.0",
"symfony/doctrine-bridge": "^4.4 || ^5.0",
"symfony/dom-crawler": "^4.4 || ^5.0",
"symfony/event-dispatcher": "^4.4 || ^5.0",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0",
"symfony/form": "^4.4 || ^5.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/http-foundation": "^4.4 || ^5.0",
"symfony/http-kernel": "^4.4 || ^5.0",
"symfony/mailer": "^4.4 || ^5.0",
"symfony/options-resolver": "^4.4 || ^5.0",
"symfony/routing": "^4.4 || ^5.0",
"symfony/security-bundle": "^4.4 || ^5.0",
"symfony/security-core": "^4.4 || ^5.0",
"symfony/security-csrf": "^4.4 || ^5.0",
"symfony/security-guard": "^4.4 || ^5.0",
"symfony/security-http": "^4.4 || ^5.0",
"symfony/templating": "^4.4 || ^5.0",
"symfony/translation": "^4.4 || ^5.0",
"symfony/twig-bundle": "^4.4 || ^5.0",
"symfony/validator": "^4.4 || ^5.0",
"twig/twig": "^2.0 || ^3.0"
"doctrine/collections": "^1.6 || ^2.0",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/orm": "^2.17 || ^3.0",
"doctrine/persistence": "^2.0 || ^3.0",
"gisostallenberg/response-content-negotiation-bundle": "^2.0",
"haydenpierce/class-finder": "^0.5.0",
"league/html-to-markdown": "^5.0",
"php-http/guzzle7-adapter": "^1.0",
"php-http/httplug-bundle": "^1.16 || ^2.0",
"rollerworks/password-strength-validator": "^1.7",
"stof/doctrine-extensions-bundle": "^1.9",
"symfony/config": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/css-selector": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/deprecation-contracts": "^3.0",
"symfony/doctrine-bridge": "^6.4 || ^7.0",
"symfony/dom-crawler": "^6.4 || ^7.0",
"symfony/event-dispatcher": "^6.4 || ^7.0",
"symfony/event-dispatcher-contracts": "^3.0",
"symfony/form": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/mailer": "^6.4 || ^7.0",
"symfony/options-resolver": "^6.4 || ^7.0",
"symfony/password-hasher": "^6.4 || ^7.0",
"symfony/routing": "^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/security-core": "^6.4 || ^7.0",
"symfony/security-csrf": "^6.4 || ^7.0",
"symfony/security-http": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"twig/twig": "^3.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.0.1",
"friendsofphp/php-cs-fixer": "^2.15",
"friendsofphp/php-cs-fixer": "^3.0",
"hwi/oauth-bundle": "^0.6.3 || ^1.0",
"icanhazstring/composer-unused": "^0.7.5",
"maglnet/composer-require-checker": "^2.0",
"nikic/php-parser": "^4.9",
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
"php-http/httplug-bundle": "^1.16",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.3",
"rector/rector": "^0.8.6",
"sensiolabs/security-checker": "^6.0",
"symfony/var-dumper": "^4.4 || ^5.0"
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^10",
"rector/rector": "^1.0",
"symfony/var-dumper": "^6.4 || ^7.0"
},
"suggest": {
"api-platform/api-pack": "Add api-platform/api-pack to add API support to the user bundle, run 'composer req api-pack' to install and follow api platform installation instructions.",
Expand All @@ -79,16 +73,14 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"ConnectHolland\\UserBundle\\": "src"
},
"files": [
"doctrine-persistence-bc-layer.php"
]
"files": []
},
"autoload-dev": {
"psr-4": {
Expand All @@ -99,9 +91,6 @@
"prefer-stable": true,
"scripts": {
"analyse": [
"composer unused --excludePackage=php-http/guzzle6-adapter --no-ansi",
"security-checker security:check",
"composer-require-checker --config-file=.composer-require-checker.json",
"phpstan analyse --level=7 src/ tests/"
],
"fix": [
Expand Down
46 changes: 21 additions & 25 deletions src/Controller/Account/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
use GisoStallenberg\Bundle\ResponseContentNegotiationBundle\Content\ResultData;
use GisoStallenberg\Bundle\ResponseContentNegotiationBundle\Content\ResultInterface;
use GisoStallenberg\Bundle\ResponseContentNegotiationBundle\Content\ResultServiceLocatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;

Expand All @@ -34,7 +34,7 @@
final class AccountController
{
/**
* @var UserPasswordEncoderInterface
* @var UserPasswordHasherInterface
*/
private $encoder;

Expand Down Expand Up @@ -63,7 +63,7 @@ final class AccountController
*/
private $groups = ['account'];

public function __construct(UserPasswordEncoderInterface $encoder, EventDispatcherInterface $eventDispatcher, Environment $twig, ManagerRegistry $registry, TokenStorageInterface $tokenStorage)
public function __construct(UserPasswordHasherInterface $encoder, EventDispatcherInterface $eventDispatcher, Environment $twig, ManagerRegistry $registry, TokenStorageInterface $tokenStorage)
{
$this->encoder = $encoder;
$this->eventDispatcher = $eventDispatcher;
Expand All @@ -72,16 +72,14 @@ public function __construct(UserPasswordEncoderInterface $encoder, EventDispatch
$this->tokenStorage = $tokenStorage;
}

/**
* @Route(
* {"en"="/account/details", "nl"="/account/gegevens"},
* name="connectholland_user_account_account",
* methods={"GET", "POST"},
* defaults={"formName"="ConnectHolland\UserBundle\Form\Account\AccountType"}
* )
* @Route("/api/account/details", name="connectholland_user_account_account.api", methods={"GET", "POST"}, defaults={"formName"="ConnectHolland\UserBundle\Form\Account\AccountType"})
* @IsGranted("IS_AUTHENTICATED_FULLY")
*/
#[Route(
path: ['en' => '/account/details', 'nl' => '/account/gegevens'],
name: 'connectholland_user_account_account',
methods: ['GET', 'POST'],
defaults: ['formName' => 'ConnectHolland\UserBundle\Form\Account\AccountType']
)]
#[Route(path: '/api/account/details', name: 'connectholland_user_account_account.api', methods: ['GET', 'POST'], defaults: ['formName' => 'ConnectHolland\UserBundle\Form\Account\AccountType'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function edit(ResultServiceLocatorInterface $resultServiceLocator, UserInterface $user, Request $request, FormInterface $form): ResultInterface
{
if ($form->isSubmitted() && $form->isValid()) {
Expand All @@ -98,7 +96,7 @@ public function edit(ResultServiceLocatorInterface $resultServiceLocator, UserIn
}

if (!empty($plainPassword)) {
$password = $this->encoder->encodePassword($user, $plainPassword);
$password = $this->encoder->hashPassword($user, $plainPassword);
$user->setPassword($password);
}

Expand Down Expand Up @@ -130,15 +128,13 @@ public function edit(ResultServiceLocatorInterface $resultServiceLocator, UserIn
);
}

/**
* @Route(
* {"en"="/account/delete", "nl"="/account/verwijderen"},
* name="connectholland_user_account_delete",
* methods={"GET", "POST"},
* defaults={"formName"="ConnectHolland\UserBundle\Form\AccountDeleteType"}
* )
* @IsGranted("IS_AUTHENTICATED_FULLY")
*/
#[Route(
path: ['en' => '/account/delete', 'nl' => '/account/verwijderen'],
name: 'connectholland_user_account_delete',
methods: ['GET', 'POST'],
defaults: ['formName' => 'ConnectHolland\UserBundle\Form\AccountDeleteType']
)]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function delete(UserInterface $user, Request $request, FormInterface $form): Response
{
if ($form->isSubmitted() && $form->isValid()) {
Expand Down
22 changes: 10 additions & 12 deletions src/Controller/Account/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
use GisoStallenberg\Bundle\ResponseContentNegotiationBundle\Content\ResultData;
use GisoStallenberg\Bundle\ResponseContentNegotiationBundle\Content\ResultInterface;
use GisoStallenberg\Bundle\ResponseContentNegotiationBundle\Content\ResultServiceLocatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;

Expand All @@ -44,16 +44,14 @@ public function __construct(EventDispatcherInterface $eventDispatcher, Environme
$this->twig = $twig;
}

/**
* @Route(
* {"en"="/account/profile", "nl"="/account/profiel"},
* name="connectholland_user_account_profile",
* methods={"GET", "POST"},
* defaults={"formName"="ConnectHolland\UserBundle\Form\Account\ProfileType"
* })
* @Route("/api/account/profile", name="connectholland_user_account_profile.api", methods={"GET", "POST"}, defaults={"formName"="ConnectHolland\UserBundle\Form\Account\ProfileType"})
* @IsGranted("IS_AUTHENTICATED_FULLY")
*/
#[Route(
path: ['en' => '/account/profile', 'nl' => '/account/profiel'],
name: 'connectholland_user_account_profile',
methods: ['GET', 'POST'],
defaults: ['formName' => 'ConnectHolland\UserBundle\Form\Account\ProfileType']
)]
#[Route(path: '/api/account/profile', name: 'connectholland_user_account_profile.api', methods: ['GET', 'POST'], defaults: ['formName' => 'ConnectHolland\UserBundle\Form\Account\ProfileType'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function edit(ResultServiceLocatorInterface $resultServiceLocator, Request $request, FormInterface $form): ResultInterface
{
if ($form->isSubmitted() && $form->isValid()) {
Expand Down
43 changes: 15 additions & 28 deletions src/Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\UriSigner;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

Expand All @@ -43,11 +42,6 @@ final class RegistrationController
*/
private $registry;

/**
* @var Session<mixed>
*/
private $session;

/**
* @var EventDispatcherInterface
*/
Expand All @@ -58,26 +52,21 @@ final class RegistrationController
*/
private $router;

/**
* @param Session<mixed> $session
*/
public function __construct(ManagerRegistry $registry, Session $session, EventDispatcherInterface $eventDispatcher, RouterInterface $router)
public function __construct(ManagerRegistry $registry, EventDispatcherInterface $eventDispatcher, RouterInterface $router)
{
$this->registry = $registry;
$this->session = $session;
$this->eventDispatcher = $eventDispatcher;
$this->router = $router;
}

#[Route(
path: ['en' => '/register', 'nl' => '/registreren'],
name: 'connectholland_user_registration',
methods: ['GET', 'POST'],
defaults: ['formName' => 'ConnectHolland\UserBundle\Form\RegistrationType']
)]
#[Route(path: '/api/register', name: 'connectholland_user_registration.api', methods: ['GET', 'POST'], defaults: ['formName' => 'ConnectHolland\UserBundle\Form\RegistrationType'])]
/**
* @Route(
* {"en"="/register", "nl"="/registreren"},
* name="connectholland_user_registration",
* methods={"GET", "POST"},
* defaults={"formName"="ConnectHolland\UserBundle\Form\RegistrationType"}
* )
* @Route("/api/register", name="connectholland_user_registration.api", methods={"GET", "POST"}, defaults={"formName"="ConnectHolland\UserBundle\Form\RegistrationType"})
*
* @param FormInterface<mixed> $form
*/
public function register(ResultServiceLocatorInterface $resultServiceLocator, Request $request, FormInterface $form): ResultInterface
Expand Down Expand Up @@ -120,14 +109,12 @@ public function register(ResultServiceLocatorInterface $resultServiceLocator, Re
);
}

/**
* @Route(
* {"en"="/register/confirm/{email}/{token}", "nl"="/registreren/bevestigen/{email}/{token}"},
* name="connectholland_user_registration_confirm",
* methods={"GET", "POST"}
* )
* @Route("/api/register/confirm/{email}/{token}", name="connectholland_user_registration_confirm.api", methods={"GET", "POST"})
*/
#[Route(
path: ['en' => '/register/confirm/{email}/{token}', 'nl' => '/registreren/bevestigen/{email}/{token}'],
name: 'connectholland_user_registration_confirm',
methods: ['GET', 'POST']
)]
#[Route(path: '/api/register/confirm/{email}/{token}', name: 'connectholland_user_registration_confirm.api', methods: ['GET', 'POST'])]
public function registrationConfirm(Request $request, string $email, string $token, UriSigner $uriSigner): Response
{
/** @var UserRepository $userRepository */
Expand Down
Loading