From 4fc876f879e4eadf8ecd0de321ce71d7143278db Mon Sep 17 00:00:00 2001
From: AntoineGonzalez <45924026+AntoineGonzalez@users.noreply.github.com>
Date: Thu, 8 Sep 2022 14:39:55 +0200
Subject: [PATCH 1/4] feature: user registration
---
apps/backend/composer.json | 1 +
apps/backend/composer.lock | 553 +++++++++++++++++-
apps/backend/mapping/User.orm.xml | 1 -
...08082231.php => Version20220908120753.php} | 2 +-
.../src/Controller/CourseController.php | 1 -
.../src/Controller/RegistrationController.php | 65 ++
.../backend/src/Repository/UserRepository.php | 17 +
.../src/Service/RegistrationService.php | 45 ++
apps/backend/symfony.lock | 9 +
apps/backend/templates/base.html.twig | 1 +
apps/backend/templates/login/index.html.twig | 4 +-
.../templates/registration/index.html.twig | 20 +
12 files changed, 713 insertions(+), 6 deletions(-)
rename apps/backend/migrations/{Version20220908082231.php => Version20220908120753.php} (92%)
create mode 100644 apps/backend/src/Controller/RegistrationController.php
create mode 100644 apps/backend/src/Repository/UserRepository.php
create mode 100644 apps/backend/src/Service/RegistrationService.php
create mode 100644 apps/backend/templates/registration/index.html.twig
diff --git a/apps/backend/composer.json b/apps/backend/composer.json
index b1b1642..0eaffb0 100644
--- a/apps/backend/composer.json
+++ b/apps/backend/composer.json
@@ -13,6 +13,7 @@
"symfony/console": "6.1.*",
"symfony/dotenv": "6.1.*",
"symfony/flex": "^2",
+ "symfony/form": "6.1.*",
"symfony/framework-bundle": "6.1.*",
"symfony/proxy-manager-bridge": "6.1.*",
"symfony/runtime": "6.1.*",
diff --git a/apps/backend/composer.lock b/apps/backend/composer.lock
index 60445f7..1c2905f 100644
--- a/apps/backend/composer.lock
+++ b/apps/backend/composer.lock
@@ -4,8 +4,64 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "986f079b38b32a722111a8e27c221eb1",
+ "content-hash": "0d587a168602f74b16f0b4c7a3b6e97a",
"packages": [
+ {
+ "name": "brick/math",
+ "version": "0.10.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/brick/math.git",
+ "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f",
+ "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "php-coveralls/php-coveralls": "^2.2",
+ "phpunit/phpunit": "^9.0",
+ "vimeo/psalm": "4.25.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Brick\\Math\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Arbitrary-precision arithmetic library",
+ "keywords": [
+ "Arbitrary-precision",
+ "BigInteger",
+ "BigRational",
+ "arithmetic",
+ "bigdecimal",
+ "bignum",
+ "brick",
+ "math"
+ ],
+ "support": {
+ "issues": "https://github.com/brick/math/issues",
+ "source": "https://github.com/brick/math/tree/0.10.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/BenMorel",
+ "type": "github"
+ }
+ ],
+ "time": "2022-08-10T22:54:19+00:00"
+ },
{
"name": "doctrine/annotations",
"version": "1.13.3",
@@ -1725,6 +1781,245 @@
},
"time": "2021-07-14T16:46:02+00:00"
},
+ {
+ "name": "ramsey/collection",
+ "version": "1.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ramsey/collection.git",
+ "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ramsey/collection/zipball/cccc74ee5e328031b15640b51056ee8d3bb66c0a",
+ "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.3 || ^8",
+ "symfony/polyfill-php81": "^1.23"
+ },
+ "require-dev": {
+ "captainhook/captainhook": "^5.3",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
+ "ergebnis/composer-normalize": "^2.6",
+ "fakerphp/faker": "^1.5",
+ "hamcrest/hamcrest-php": "^2",
+ "jangregor/phpstan-prophecy": "^0.8",
+ "mockery/mockery": "^1.3",
+ "phpspec/prophecy-phpunit": "^2.0",
+ "phpstan/extension-installer": "^1",
+ "phpstan/phpstan": "^0.12.32",
+ "phpstan/phpstan-mockery": "^0.12.5",
+ "phpstan/phpstan-phpunit": "^0.12.11",
+ "phpunit/phpunit": "^8.5 || ^9",
+ "psy/psysh": "^0.10.4",
+ "slevomat/coding-standard": "^6.3",
+ "squizlabs/php_codesniffer": "^3.5",
+ "vimeo/psalm": "^4.4"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Ramsey\\Collection\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ben Ramsey",
+ "email": "ben@benramsey.com",
+ "homepage": "https://benramsey.com"
+ }
+ ],
+ "description": "A PHP library for representing and manipulating collections.",
+ "keywords": [
+ "array",
+ "collection",
+ "hash",
+ "map",
+ "queue",
+ "set"
+ ],
+ "support": {
+ "issues": "https://github.com/ramsey/collection/issues",
+ "source": "https://github.com/ramsey/collection/tree/1.2.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ramsey",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/ramsey/collection",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-10-10T03:01:02+00:00"
+ },
+ {
+ "name": "ramsey/uuid",
+ "version": "4.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ramsey/uuid.git",
+ "reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ramsey/uuid/zipball/373f7bacfcf3de038778ff27dcce5672ddbf4c8a",
+ "reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a",
+ "shasum": ""
+ },
+ "require": {
+ "brick/math": "^0.8 || ^0.9 || ^0.10",
+ "ext-ctype": "*",
+ "ext-json": "*",
+ "php": "^8.0",
+ "ramsey/collection": "^1.0"
+ },
+ "replace": {
+ "rhumsaa/uuid": "self.version"
+ },
+ "require-dev": {
+ "captainhook/captainhook": "^5.10",
+ "captainhook/plugin-composer": "^5.3",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
+ "doctrine/annotations": "^1.8",
+ "ergebnis/composer-normalize": "^2.15",
+ "mockery/mockery": "^1.3",
+ "paragonie/random-lib": "^2",
+ "php-mock/php-mock": "^2.2",
+ "php-mock/php-mock-mockery": "^1.3",
+ "php-parallel-lint/php-parallel-lint": "^1.1",
+ "phpbench/phpbench": "^1.0",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^0.12",
+ "phpstan/phpstan-mockery": "^0.12",
+ "phpstan/phpstan-phpunit": "^0.12",
+ "phpunit/phpunit": "^8.5 || ^9",
+ "slevomat/coding-standard": "^7.0",
+ "squizlabs/php_codesniffer": "^3.5",
+ "vimeo/psalm": "^4.9"
+ },
+ "suggest": {
+ "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
+ "ext-ctype": "Enables faster processing of character classification using ctype functions.",
+ "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
+ "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
+ "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
+ "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
+ },
+ "type": "library",
+ "extra": {
+ "captainhook": {
+ "force-install": true
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/functions.php"
+ ],
+ "psr-4": {
+ "Ramsey\\Uuid\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
+ "keywords": [
+ "guid",
+ "identifier",
+ "uuid"
+ ],
+ "support": {
+ "issues": "https://github.com/ramsey/uuid/issues",
+ "source": "https://github.com/ramsey/uuid/tree/4.4.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ramsey",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-08-05T17:58:37+00:00"
+ },
+ {
+ "name": "ramsey/uuid-doctrine",
+ "version": "1.8.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ramsey/uuid-doctrine.git",
+ "reference": "1a6f235ba3faf1cd9ba18daf5b54d8dc9d3bc7d0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ramsey/uuid-doctrine/zipball/1a6f235ba3faf1cd9ba18daf5b54d8dc9d3bc7d0",
+ "reference": "1a6f235ba3faf1cd9ba18daf5b54d8dc9d3bc7d0",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/dbal": "^2.5 || ^3.0",
+ "php": "^5.4 || ^7 || ^8",
+ "ramsey/uuid": "^3.5 || ^4"
+ },
+ "require-dev": {
+ "doctrine/orm": "^2.5",
+ "mockery/mockery": "^0.9.11 || ^1",
+ "php-parallel-lint/php-parallel-lint": "^1",
+ "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7 || ^8 || ^9",
+ "squizlabs/php_codesniffer": "^3.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Ramsey\\Uuid\\Doctrine\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ben Ramsey",
+ "email": "ben@benramsey.com",
+ "homepage": "https://benramsey.com"
+ }
+ ],
+ "description": "Use ramsey/uuid as a Doctrine field type.",
+ "keywords": [
+ "database",
+ "doctrine",
+ "guid",
+ "identifier",
+ "uuid"
+ ],
+ "support": {
+ "issues": "https://github.com/ramsey/uuid-doctrine/issues",
+ "source": "https://github.com/ramsey/uuid-doctrine/tree/1.8.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ramsey",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid-doctrine",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-15T23:54:44+00:00"
+ },
{
"name": "symfony/cache",
"version": "v6.1.3",
@@ -2840,6 +3135,108 @@
],
"time": "2022-08-07T09:39:47+00:00"
},
+ {
+ "name": "symfony/form",
+ "version": "v6.1.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/form.git",
+ "reference": "0a1a3ea071a216e2902cebe0b47750ca51f12f27"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/form/zipball/0a1a3ea071a216e2902cebe0b47750ca51f12f27",
+ "reference": "0a1a3ea071a216e2902cebe0b47750ca51f12f27",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/event-dispatcher": "^5.4|^6.0",
+ "symfony/options-resolver": "^5.4|^6.0",
+ "symfony/polyfill-ctype": "~1.8",
+ "symfony/polyfill-intl-icu": "^1.21",
+ "symfony/polyfill-mbstring": "~1.0",
+ "symfony/property-access": "^5.4|^6.0",
+ "symfony/service-contracts": "^1.1|^2|^3"
+ },
+ "conflict": {
+ "phpunit/phpunit": "<5.4.3",
+ "symfony/console": "<5.4",
+ "symfony/dependency-injection": "<5.4",
+ "symfony/doctrine-bridge": "<5.4",
+ "symfony/error-handler": "<5.4",
+ "symfony/framework-bundle": "<5.4",
+ "symfony/http-kernel": "<5.4",
+ "symfony/translation": "<5.4",
+ "symfony/translation-contracts": "<1.1.7",
+ "symfony/twig-bridge": "<5.4"
+ },
+ "require-dev": {
+ "doctrine/collections": "~1.0",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/console": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/expression-language": "^5.4|^6.0",
+ "symfony/html-sanitizer": "^6.1",
+ "symfony/http-foundation": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/intl": "^5.4|^6.0",
+ "symfony/security-csrf": "^5.4|^6.0",
+ "symfony/translation": "^5.4|^6.0",
+ "symfony/uid": "^5.4|^6.0",
+ "symfony/validator": "^5.4|^6.0",
+ "symfony/var-dumper": "^5.4|^6.0"
+ },
+ "suggest": {
+ "symfony/security-csrf": "For protecting forms against CSRF attacks.",
+ "symfony/twig-bridge": "For templating with Twig.",
+ "symfony/validator": "For form validation."
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Form\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Allows to easily create, process and reuse HTML forms",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/form/tree/v6.1.4"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-08-09T09:57:18+00:00"
+ },
{
"name": "symfony/framework-bundle",
"version": "v6.1.4",
@@ -3176,6 +3573,73 @@
],
"time": "2022-08-26T14:50:30+00:00"
},
+ {
+ "name": "symfony/options-resolver",
+ "version": "v6.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/options-resolver.git",
+ "reference": "a3016f5442e28386ded73c43a32a5b68586dd1c4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a3016f5442e28386ded73c43a32a5b68586dd1c4",
+ "reference": "a3016f5442e28386ded73c43a32a5b68586dd1c4",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "symfony/deprecation-contracts": "^2.1|^3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\OptionsResolver\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides an improved replacement for the array_replace PHP function",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "config",
+ "configuration",
+ "options"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/options-resolver/tree/v6.1.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-02-25T11:15:52+00:00"
+ },
{
"name": "symfony/password-hasher",
"version": "v6.1.3",
@@ -3329,6 +3793,93 @@
],
"time": "2022-05-24T11:49:31+00:00"
},
+ {
+ "name": "symfony/polyfill-intl-icu",
+ "version": "v1.26.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-intl-icu.git",
+ "reference": "e407643d610e5f2c8a4b14189150f68934bf5e48"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/e407643d610e5f2c8a4b14189150f68934bf5e48",
+ "reference": "e407643d610e5f2c8a4b14189150f68934bf5e48",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "suggest": {
+ "ext-intl": "For best performance and support of other locales than \"en\""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.26-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Icu\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ],
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for intl's ICU-related data and classes",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "icu",
+ "intl",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.26.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-05-24T11:49:31+00:00"
+ },
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.26.0",
diff --git a/apps/backend/mapping/User.orm.xml b/apps/backend/mapping/User.orm.xml
index fa22543..8284643 100644
--- a/apps/backend/mapping/User.orm.xml
+++ b/apps/backend/mapping/User.orm.xml
@@ -12,7 +12,6 @@
type="uuid"
column="id"
>
-
{{ error.messageKey|trans(error.messageData, 'security') }}
-