Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register a new app user #165

Merged
merged 3 commits into from
Oct 3, 2020
Merged
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
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ MAILER_URL=null://localhost
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
###< nelmio/cors-bundle ###

###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=doctrine://default
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
###< symfony/messenger ###
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"App\\Entity\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Entity/",
"App\\EventListener\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/EventListener/",
"App\\EventSubscriber\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/EventSubscriber/",
"App\\Fixture\\": "src/Monofony/Plugin/FixturesPlugin/Recipe/src/Fixture/",
"App\\Fixture\\": "src/Monofony/Pack/FixturesPack/Recipe/src/Fixture/",
"App\\Form\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Form/",
"App\\Formatter\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Formatter/",
"App\\Installer\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Installer/",
"App\\Installer\\Checker\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Installer/Checker/",
"App\\Message\\": "src/Monofony/Pack/ApiPack/Recipe/src/Message/",
"App\\MessageHandler\\": "src/Monofony/Pack/ApiPack/Recipe/src/MessageHandler/",
"App\\Migrations\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Migrations/",
"App\\Repository\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Repository/",
"App\\Validator\\": "src/Monofony/Bundle/CoreBundle/Recipe/src/Validator/",
Expand Down Expand Up @@ -48,7 +50,7 @@
"App\\Tests\\Behat\\Exception\\": "src/Monofony/Bundle/CoreBundle/Recipe/tests/Behat/Exception/",
"App\\Tests\\Behat\\Page\\Frontend\\": "src/Monofony/Bundle/FrontBundle/Recipe/tests/Behat/Page/Frontend/",
"App\\Tests\\Behat\\Service\\": "src/Monofony/Bundle/CoreBundle/Recipe/tests/Behat/Service/",
"App\\Tests\\Controller\\": "src/Monofony/Bundle/ApiBundle/Recipe/tests/Controller/"
"App\\Tests\\Controller\\": "src/Monofony/Pack/ApiPack/Recipe/tests/Controller/"
}
},
"require": {
Expand Down Expand Up @@ -76,6 +78,7 @@
"sylius/user-bundle": "^1.6",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.2",
"symfony/messenger": "4.4.*",
"symfony/monolog-bundle": "^3.3",
"symfony/polyfill-php80": "^1.15",
"symfony/proxy-manager-bridge": "4.4.*",
Expand Down
78 changes: 77 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@
Monofony\Bundle\CoreBundle\MonofonyCoreBundle::class => ['all' => true],
Monofony\Bundle\AdminBundle\MonofonyAdminBundle::class => ['all' => true],
Monofony\Bundle\FrontBundle\MonofonyFrontBundle::class => ['all' => true],
Monofony\Bundle\ApiBundle\MonofonyApiBundle::class => ['all' => true],
Monofony\Plugin\FixturesPlugin\MonofonyFixturesPlugin::class => ['all' => true],
];
4 changes: 3 additions & 1 deletion config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
api_platform:
version: !php/const App\Kernel::VERSION
mapping:
paths: ['%kernel.project_dir%/src/Monofony/Bundle/CoreBundle/Recipe/src/Entity']
paths:
- '%kernel.project_dir%/src/Monofony/Bundle/CoreBundle/Recipe/src/Entity'
- '%kernel.project_dir%/src/Monofony/Pack/ApiPack/Recipe/config/api_platform/resources'
patch_formats:
json: ['application/merge-patch+json']
swagger:
Expand Down
6 changes: 5 additions & 1 deletion config/packages/framework.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
framework:
#esi: ~
translator: { fallbacks: ["%locale%"] }
translator:
fallbacks: ["%locale%"]
paths:
- '%kernel.project_dir%/src/Monofony/Bundle/CoreBundle/Recipe/translations'
secret: '%env(APP_SECRET)%'
form: ~
csrf_protection: ~
Expand All @@ -17,3 +20,4 @@ framework:
http_method_override: true
php_errors:
log: true

14 changes: 14 additions & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed

transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'

routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
2 changes: 2 additions & 0 deletions config/packages/monofony_fixtures.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "../../src/Monofony/Pack/FixturesPack/Recipe/config/packages/monofony_fixtures.yaml" }
2 changes: 0 additions & 2 deletions config/packages/monofony_fixtures_plugin.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ app_frontend:
resource: "../src/Monofony/Bundle/FrontBundle/Recipe/config/routes/frontend.yaml"

app_api:
resource: "../src/Monofony/Bundle/ApiBundle/Recipe/config/routes/api.yaml"
resource: "../src/Monofony/Pack/ApiPack/Recipe/config/routes/api.yaml"
4 changes: 2 additions & 2 deletions config/services/monofony_fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ services:

app_fixture:
namespace: App\
resource: '../../src/Monofony/Plugin/FixturesPlugin/Recipe/src/*'
exclude: '../../src/Monofony/Plugin/FixturesPlugin/Recipe/src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
resource: '../../src/Monofony/Pack/FixturesPack/Recipe/src/*'
exclude: '../../src/Monofony/Pack/FixturesPack/Recipe/src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
3 changes: 2 additions & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"src/Monofony/Bundle/CoreBundle/Recipe/src",
"src/Admin/recipe/src",
"src/Monofony/Bundle/FrontBundle/Recipe/src",
"src/Monofony/Plugin/FixturesPlugin/Recipe/src"
"src/Monofony/Pack/FixturesPack/Recipe/src",
"src/Monofony/Pack/ApiPack/Recipe/src"
],
"excludes": [
"Command",
Expand Down
20 changes: 0 additions & 20 deletions src/Monofony/Bundle/ApiBundle/MonofonyApiBundle.php

This file was deleted.

22 changes: 0 additions & 22 deletions src/Monofony/Bundle/ApiBundle/composer.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of mz_067_s_ccpa_thermotool.
*
* (c) Mobizel
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\Validator\Constraints;

use Symfony\Component\Validator\Constraint;

/**
* @Annotation
*/
final class UniqueAppUserEmail extends Constraint
{
/** @var string */
public $message = 'sylius.user.email.unique';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\Validator\Constraints;

use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Webmozart\Assert\Assert;

final class UniqueAppUserEmailValidator extends ConstraintValidator
{
private $canonicalizer;
private $appUserRepository;

public function __construct(CanonicalizerInterface $canonicalizer, UserRepositoryInterface $appUserRepository)
{
$this->canonicalizer = $canonicalizer;
$this->appUserRepository = $appUserRepository;
}

public function validate($value, Constraint $constraint): void
{
if (null === $value) {
return;
}

/* @var UniqueAppUserEmail $constraint */
Assert::isInstanceOf($constraint, UniqueAppUserEmail::class);

$emailCanonical = $this->canonicalizer->canonicalize($value);
$shopUser = $this->appUserRepository->findOneByEmail($emailCanonical);

if (null === $shopUser) {
return;
}

$this->context->addViolation($constraint->message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sylius:
user:
email:
unique: This email is already used.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sylius:
user:
email:
unique: Cet e-mail est déjà utilisé.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
App\Message\RegisterAppUser:
attributes:
messenger: true
output: false
validation_groups: ["Default", "sylius"]
itemOperations: []
collectionOperations:
post:
path: /register
openapi_context:
summary: Registers an app user
validation_groups: ["Default", "sylius"]
Loading