From 5be77eeba1dd7a4b30055ef5837d8ffc721fbda2 Mon Sep 17 00:00:00 2001 From: tim Date: Sun, 2 Apr 2023 19:34:00 +0200 Subject: [PATCH] Create everything required to login and register --- composer.json | 13 +- composer.lock | 887 +++++++++++++++++++++++++- config/bundles.php | 3 + config/packages/debug.yaml | 5 + config/packages/monolog.yaml | 61 ++ config/packages/security.yaml | 24 +- config/packages/validator.yaml | 13 + config/packages/web_profiler.yaml | 17 + config/routes/web_profiler.yaml | 8 + config/services.yaml | 5 +- deploy.php | 108 ++++ src/Controller/.gitignore | 0 src/Controller/HomeController.php | 19 + src/Controller/SecurityController.php | 72 +++ src/Controller/UserController.php | 63 ++ src/Form/ProfileType.php | 49 ++ src/Form/RegistrationFormType.php | 64 ++ src/Service/LastRelease.php | 68 ++ symfony.lock | 49 ++ templates/base.html.twig | 19 - templates/base/base.html.twig | 70 ++ templates/base/navbar.html.twig | 33 + templates/security/login.html.twig | 32 + templates/security/register.html.twig | 6 + templates/simple.html.twig | 5 + templates/user/profile.html.twig | 26 + 26 files changed, 1664 insertions(+), 55 deletions(-) create mode 100644 config/packages/debug.yaml create mode 100644 config/packages/monolog.yaml create mode 100644 config/packages/validator.yaml create mode 100644 config/packages/web_profiler.yaml create mode 100644 config/routes/web_profiler.yaml create mode 100644 deploy.php delete mode 100644 src/Controller/.gitignore create mode 100644 src/Controller/HomeController.php create mode 100644 src/Controller/SecurityController.php create mode 100644 src/Controller/UserController.php create mode 100644 src/Form/ProfileType.php create mode 100644 src/Form/RegistrationFormType.php create mode 100644 src/Service/LastRelease.php delete mode 100644 templates/base.html.twig create mode 100644 templates/base/base.html.twig create mode 100644 templates/base/navbar.html.twig create mode 100644 templates/security/login.html.twig create mode 100644 templates/security/register.html.twig create mode 100644 templates/simple.html.twig create mode 100644 templates/user/profile.html.twig diff --git a/composer.json b/composer.json index e6b430d..92ddee6 100644 --- a/composer.json +++ b/composer.json @@ -13,14 +13,24 @@ "symfony/console": "6.2.*", "symfony/dotenv": "6.2.*", "symfony/flex": "^2", + "symfony/form": "6.2.*", "symfony/framework-bundle": "6.2.*", + "symfony/monolog-bundle": "^3.0", "symfony/runtime": "6.2.*", "symfony/security-bundle": "6.2.*", "symfony/twig-bundle": "6.2.*", + "symfony/validator": "6.2.*", "symfony/yaml": "6.2.*", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0" }, + "require-dev": { + "deployer/deployer": "^7.3", + "symfony/debug-bundle": "6.2.*", + "symfony/maker-bundle": "^1.48", + "symfony/stopwatch": "6.2.*", + "symfony/web-profiler-bundle": "6.2.*" + }, "config": { "allow-plugins": { "php-http/discovery": true, @@ -68,8 +78,5 @@ "allow-contrib": false, "require": "6.2.*" } - }, - "require-dev": { - "symfony/maker-bundle": "^1.48" } } diff --git a/composer.lock b/composer.lock index 05fe6c0..efb15dc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9db7f9b50a3a3118a436bbd3e9e757c4", + "content-hash": "5cd09d345b4ecefaece6f03c919d953e", "packages": [ { "name": "doctrine/cache", @@ -1315,6 +1315,107 @@ }, "time": "2022-05-23T21:33:49+00:00" }, + { + "name": "monolog/monolog", + "version": "3.3.1", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "9b5daeaffce5b926cac47923798bba91059e60e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/9b5daeaffce5b926cac47923798bba91059e60e2", + "reference": "9b5daeaffce5b926cac47923798bba91059e60e2", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" + }, + "provide": { + "psr/log-implementation": "3.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7 || ^8", + "ext-json": "*", + "graylog2/gelf-php": "^1.4.2 || ^2@dev", + "guzzlehttp/guzzle": "^7.4.5", + "guzzlehttp/psr7": "^2.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4 || ^3", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "^9.5.26", + "predis/predis": "^1.1 || ^2", + "ruflin/elastica": "^7", + "symfony/mailer": "^5.4 || ^6", + "symfony/mime": "^5.4 || ^6" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "ext-openssl": "Required to send log messages using SSL", + "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/3.3.1" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2023-02-06T13:46:10+00:00" + }, { "name": "psr/cache", "version": "3.0.0", @@ -1771,16 +1872,16 @@ }, { "name": "symfony/console", - "version": "v6.2.7", + "version": "v6.2.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45" + "reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cbad09eb8925b6ad4fb721c7a179344dc4a19d45", - "reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45", + "url": "https://api.github.com/repos/symfony/console/zipball/3582d68a64a86ec25240aaa521ec8bc2342b369b", + "reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b", "shasum": "" }, "require": { @@ -1842,12 +1943,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.2.7" + "source": "https://github.com/symfony/console/tree/v6.2.8" }, "funding": [ { @@ -1863,7 +1964,7 @@ "type": "tidelift" } ], - "time": "2023-02-25T17:00:03+00:00" + "time": "2023-03-29T21:42:15+00:00" }, { "name": "symfony/dependency-injection", @@ -2136,16 +2237,16 @@ }, { "name": "symfony/dotenv", - "version": "v6.2.7", + "version": "v6.2.8", "source": { "type": "git", "url": "https://github.com/symfony/dotenv.git", - "reference": "f2b09b7ee21458779df000bd24020b6e9955b393" + "reference": "4481aa45be7a11d2335c1d5b5bbe2f0c6199b105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dotenv/zipball/f2b09b7ee21458779df000bd24020b6e9955b393", - "reference": "f2b09b7ee21458779df000bd24020b6e9955b393", + "url": "https://api.github.com/repos/symfony/dotenv/zipball/4481aa45be7a11d2335c1d5b5bbe2f0c6199b105", + "reference": "4481aa45be7a11d2335c1d5b5bbe2f0c6199b105", "shasum": "" }, "require": { @@ -2190,7 +2291,7 @@ "environment" ], "support": { - "source": "https://github.com/symfony/dotenv/tree/v6.2.7" + "source": "https://github.com/symfony/dotenv/tree/v6.2.8" }, "funding": [ { @@ -2206,7 +2307,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:44:56+00:00" + "time": "2023-03-10T10:06:03+00:00" }, { "name": "symfony/error-handler", @@ -2633,6 +2734,110 @@ ], "time": "2023-02-18T08:03:15+00:00" }, + { + "name": "symfony/form", + "version": "v6.2.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/form.git", + "reference": "751efa84f868337c63e29560c02cff7ae27d874b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/form/zipball/751efa84f868337c63e29560c02cff7ae27d874b", + "reference": "751efa84f868337c63e29560c02cff7ae27d874b", + "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.21|>=6,<6.2.7", + "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.21|>=6,<6.2.7" + }, + "require-dev": { + "doctrine/collections": "^1.0|^2.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-core": "^6.2", + "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-core": "For hashing users passwords.", + "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.2.8" + }, + "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": "2023-03-31T11:20:06+00:00" + }, { "name": "symfony/framework-bundle", "version": "v6.2.7", @@ -2973,6 +3178,237 @@ ], "time": "2023-02-28T13:26:41+00:00" }, + { + "name": "symfony/monolog-bridge", + "version": "v6.2.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/monolog-bridge.git", + "reference": "34700f2e5c7e9eae78f8e59fc02399dd8f110cae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/monolog-bridge/zipball/34700f2e5c7e9eae78f8e59fc02399dd8f110cae", + "reference": "34700f2e5c7e9eae78f8e59fc02399dd8f110cae", + "shasum": "" + }, + "require": { + "monolog/monolog": "^1.25.1|^2|^3", + "php": ">=8.1", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/service-contracts": "^1.1|^2|^3" + }, + "conflict": { + "symfony/console": "<5.4", + "symfony/http-foundation": "<5.4", + "symfony/security-core": "<6.0" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/mailer": "^5.4|^6.0", + "symfony/messenger": "^5.4|^6.0", + "symfony/mime": "^5.4|^6.0", + "symfony/security-core": "^6.0", + "symfony/var-dumper": "^5.4|^6.0" + }, + "suggest": { + "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings.", + "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", + "symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler." + }, + "type": "symfony-bridge", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\Monolog\\": "" + }, + "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 integration for Monolog with various Symfony components", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/monolog-bridge/tree/v6.2.8" + }, + "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": "2023-03-09T16:20:02+00:00" + }, + { + "name": "symfony/monolog-bundle", + "version": "v3.8.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/monolog-bundle.git", + "reference": "a41bbcdc1105603b6d73a7d9a43a3788f8e0fb7d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/monolog-bundle/zipball/a41bbcdc1105603b6d73a7d9a43a3788f8e0fb7d", + "reference": "a41bbcdc1105603b6d73a7d9a43a3788f8e0fb7d", + "shasum": "" + }, + "require": { + "monolog/monolog": "^1.22 || ^2.0 || ^3.0", + "php": ">=7.1.3", + "symfony/config": "~4.4 || ^5.0 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", + "symfony/http-kernel": "~4.4 || ^5.0 || ^6.0", + "symfony/monolog-bridge": "~4.4 || ^5.0 || ^6.0" + }, + "require-dev": { + "symfony/console": "~4.4 || ^5.0 || ^6.0", + "symfony/phpunit-bridge": "^5.2 || ^6.0", + "symfony/yaml": "~4.4 || ^5.0 || ^6.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bundle\\MonologBundle\\": "" + }, + "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": "Symfony MonologBundle", + "homepage": "https://symfony.com", + "keywords": [ + "log", + "logging" + ], + "support": { + "issues": "https://github.com/symfony/monolog-bundle/issues", + "source": "https://github.com/symfony/monolog-bundle/tree/v3.8.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-10T14:24:36+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v6.2.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "aa0e85b53bbb2b4951960efd61d295907eacd629" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/aa0e85b53bbb2b4951960efd61d295907eacd629", + "reference": "aa0e85b53bbb2b4951960efd61d295907eacd629", + "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.2.7" + }, + "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": "2023-02-14T08:44:56+00:00" + }, { "name": "symfony/password-hasher", "version": "v6.2.7", @@ -3126,6 +3562,93 @@ ], "time": "2022-11-03T14:55:06+00:00" }, + { + "name": "symfony/polyfill-intl-icu", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-icu.git", + "reference": "a3d9148e2c363588e05abbdd4ee4f971f0a5330c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/a3d9148e2c363588e05abbdd4ee4f971f0a5330c", + "reference": "a3d9148e2c363588e05abbdd4ee4f971f0a5330c", + "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.27-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.27.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-11-03T14:55:06+00:00" + }, { "name": "symfony/polyfill-intl-normalizer", "version": "v1.27.0", @@ -3552,16 +4075,16 @@ }, { "name": "symfony/runtime", - "version": "v6.2.7", + "version": "v6.2.8", "source": { "type": "git", "url": "https://github.com/symfony/runtime.git", - "reference": "111b9d617d0cfc71d44baf01eb9951517fd8b739" + "reference": "f8b0751b33888329be8f8f0481bb81d279ec4157" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/runtime/zipball/111b9d617d0cfc71d44baf01eb9951517fd8b739", - "reference": "111b9d617d0cfc71d44baf01eb9951517fd8b739", + "url": "https://api.github.com/repos/symfony/runtime/zipball/f8b0751b33888329be8f8f0481bb81d279ec4157", + "reference": "f8b0751b33888329be8f8f0481bb81d279ec4157", "shasum": "" }, "require": { @@ -3607,8 +4130,11 @@ ], "description": "Enables decoupling PHP applications from global state", "homepage": "https://symfony.com", + "keywords": [ + "runtime" + ], "support": { - "source": "https://github.com/symfony/runtime/tree/v6.2.7" + "source": "https://github.com/symfony/runtime/tree/v6.2.8" }, "funding": [ { @@ -3624,20 +4150,20 @@ "type": "tidelift" } ], - "time": "2023-02-02T07:44:01+00:00" + "time": "2023-03-14T15:48:35+00:00" }, { "name": "symfony/security-bundle", - "version": "v6.2.7", + "version": "v6.2.8", "source": { "type": "git", "url": "https://github.com/symfony/security-bundle.git", - "reference": "601bcc14b6e8c168dc5985d31cfdfd11bd07b50b" + "reference": "c781ba5ab5f71a5c8bd5fce5b4c8b6ad9eb7f3d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-bundle/zipball/601bcc14b6e8c168dc5985d31cfdfd11bd07b50b", - "reference": "601bcc14b6e8c168dc5985d31cfdfd11bd07b50b", + "url": "https://api.github.com/repos/symfony/security-bundle/zipball/c781ba5ab5f71a5c8bd5fce5b4c8b6ad9eb7f3d5", + "reference": "c781ba5ab5f71a5c8bd5fce5b4c8b6ad9eb7f3d5", "shasum": "" }, "require": { @@ -3708,7 +4234,7 @@ "description": "Provides a tight integration of the Security component into the Symfony full-stack framework", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/security-bundle/tree/v6.2.7" + "source": "https://github.com/symfony/security-bundle/tree/v6.2.8" }, "funding": [ { @@ -3724,7 +4250,7 @@ "type": "tidelift" } ], - "time": "2023-02-21T12:32:47+00:00" + "time": "2023-03-10T10:06:03+00:00" }, { "name": "symfony/security-core", @@ -4496,6 +5022,114 @@ ], "time": "2023-02-14T08:44:56+00:00" }, + { + "name": "symfony/validator", + "version": "v6.2.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/validator.git", + "reference": "c63584f84edbdba9d2519f888350dd90615abe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/validator/zipball/c63584f84edbdba9d2519f888350dd90615abe35", + "reference": "c63584f84edbdba9d2519f888350dd90615abe35", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation-contracts": "^1.1|^2|^3" + }, + "conflict": { + "doctrine/annotations": "<1.13", + "doctrine/lexer": "<1.1", + "phpunit/phpunit": "<5.4.3", + "symfony/dependency-injection": "<5.4", + "symfony/expression-language": "<5.4", + "symfony/http-kernel": "<5.4", + "symfony/intl": "<5.4", + "symfony/property-info": "<5.4", + "symfony/translation": "<5.4", + "symfony/yaml": "<5.4" + }, + "require-dev": { + "doctrine/annotations": "^1.13|^2", + "egulias/email-validator": "^2.1.10|^3|^4", + "symfony/cache": "^5.4|^6.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/finder": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/intl": "^5.4|^6.0", + "symfony/mime": "^5.4|^6.0", + "symfony/property-access": "^5.4|^6.0", + "symfony/property-info": "^5.4|^6.0", + "symfony/translation": "^5.4|^6.0", + "symfony/yaml": "^5.4|^6.0" + }, + "suggest": { + "egulias/email-validator": "Strict (RFC compliant) email validation", + "psr/cache-implementation": "For using the mapping cache.", + "symfony/config": "", + "symfony/expression-language": "For using the Expression validator and the ExpressionLanguageSyntax constraints", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/property-access": "For accessing properties within comparison constraints", + "symfony/property-info": "To automatically add NotNull and Type constraints", + "symfony/translation": "For translating validation errors.", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Validator\\": "" + }, + "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 tools to validate values", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/validator/tree/v6.2.8" + }, + "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": "2023-03-20T16:06:02+00:00" + }, { "name": "symfony/var-dumper", "version": "v6.2.7", @@ -4889,6 +5523,49 @@ } ], "packages-dev": [ + { + "name": "deployer/deployer", + "version": "v7.3.0", + "source": { + "type": "git", + "url": "https://github.com/deployphp/deployer.git", + "reference": "de2367892e2475e4ad42b4d86d8cfef4f2387471" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/deployphp/deployer/zipball/de2367892e2475e4ad42b4d86d8cfef4f2387471", + "reference": "de2367892e2475e4ad42b4d86d8cfef4f2387471", + "shasum": "" + }, + "bin": [ + "dep" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Medvedev", + "email": "anton@medv.io" + } + ], + "description": "Deployment Tool", + "homepage": "https://deployer.org", + "support": { + "docs": "https://deployer.org/docs", + "issues": "https://github.com/deployphp/deployer/issues", + "source": "https://github.com/deployphp/deployer" + }, + "funding": [ + { + "url": "https://github.com/sponsors/antonmedv", + "type": "github" + } + ], + "time": "2023-03-24T10:50:39+00:00" + }, { "name": "nikic/php-parser", "version": "v4.15.4", @@ -4945,6 +5622,84 @@ }, "time": "2023-03-05T19:49:14+00:00" }, + { + "name": "symfony/debug-bundle", + "version": "v6.2.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug-bundle.git", + "reference": "8ff6c96d09c462beade7512137899e400c76d994" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug-bundle/zipball/8ff6c96d09c462beade7512137899e400c76d994", + "reference": "8ff6c96d09c462beade7512137899e400c76d994", + "shasum": "" + }, + "require": { + "ext-xml": "*", + "php": ">=8.1", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/twig-bridge": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" + }, + "conflict": { + "symfony/config": "<5.4", + "symfony/dependency-injection": "<5.4" + }, + "require-dev": { + "symfony/config": "^5.4|^6.0", + "symfony/web-profiler-bundle": "^5.4|^6.0" + }, + "suggest": { + "symfony/config": "For service container configuration", + "symfony/dependency-injection": "For using as a service from the container" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\DebugBundle\\": "" + }, + "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 a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/debug-bundle/tree/v6.2.7" + }, + "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": "2023-02-14T08:44:56+00:00" + }, { "name": "symfony/maker-bundle", "version": "v1.48.0", @@ -5037,6 +5792,84 @@ } ], "time": "2022-11-14T10:48:46+00:00" + }, + { + "name": "symfony/web-profiler-bundle", + "version": "v6.2.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/web-profiler-bundle.git", + "reference": "0d183e0a69652e348007e97ffff8d3ded9cc6d2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/0d183e0a69652e348007e97ffff8d3ded9cc6d2d", + "reference": "0d183e0a69652e348007e97ffff8d3ded9cc6d2d", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/config": "^5.4|^6.0", + "symfony/framework-bundle": "^5.4|^6.0", + "symfony/http-kernel": "^6.1", + "symfony/routing": "^5.4|^6.0", + "symfony/twig-bundle": "^5.4|^6.0", + "twig/twig": "^2.13|^3.0.4" + }, + "conflict": { + "symfony/form": "<5.4", + "symfony/mailer": "<5.4", + "symfony/messenger": "<5.4" + }, + "require-dev": { + "symfony/browser-kit": "^5.4|^6.0", + "symfony/console": "^5.4|^6.0", + "symfony/css-selector": "^5.4|^6.0", + "symfony/stopwatch": "^5.4|^6.0" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\WebProfilerBundle\\": "" + }, + "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 a development tool that gives detailed information about the execution of any request", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/web-profiler-bundle/tree/v6.2.7" + }, + "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": "2023-02-21T16:32:03+00:00" } ], "aliases": [], @@ -5050,5 +5883,5 @@ "ext-iconv": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/config/bundles.php b/config/bundles.php index aeee2e5..c5a5736 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -8,4 +8,7 @@ return [ Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], + Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], ]; diff --git a/config/packages/debug.yaml b/config/packages/debug.yaml new file mode 100644 index 0000000..ad874af --- /dev/null +++ b/config/packages/debug.yaml @@ -0,0 +1,5 @@ +when@dev: + debug: + # Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser. + # See the "server:dump" command to start a new server. + dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%" diff --git a/config/packages/monolog.yaml b/config/packages/monolog.yaml new file mode 100644 index 0000000..8c9efa9 --- /dev/null +++ b/config/packages/monolog.yaml @@ -0,0 +1,61 @@ +monolog: + channels: + - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists + +when@dev: + monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + channels: ["!event"] + # uncomment to get logging in your browser + # you may have to allow bigger header sizes in your Web server configuration + #firephp: + # type: firephp + # level: info + #chromephp: + # type: chromephp + # level: info + console: + type: console + process_psr_3_messages: false + channels: ["!event", "!doctrine", "!console"] + +when@test: + monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + excluded_http_codes: [404, 405] + channels: ["!event"] + nested: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + +when@prod: + monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + excluded_http_codes: [404, 405] + buffer_size: 50 # How many messages should be saved? Prevent memory leaks + nested: + type: stream + path: php://stderr + level: debug + formatter: monolog.formatter.json + console: + type: console + process_psr_3_messages: false + channels: ["!event", "!doctrine"] + deprecation: + type: stream + channels: [deprecation] + path: php://stderr diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 663fbf5..bfb1ff6 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -5,7 +5,7 @@ security: # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider providers: # used to reload user from session & other features (e.g. switch_user) - app_user_provider: + user_provider: entity: class: App\Entity\User property: username @@ -15,7 +15,19 @@ security: security: false main: lazy: true - provider: app_user_provider + provider: user_provider + logout: + path: logout + form_login: + login_path: login + check_path: login + remember_me: + secret: '%kernel.secret%' # required + lifetime: 2419200 # 4 weeks in seconds + + secured_area: + form_login: + enable_csrf: true # activate different ways to authenticate # https://symfony.com/doc/current/security.html#the-firewall @@ -26,8 +38,12 @@ security: # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: - # - { path: ^/admin, roles: ROLE_ADMIN } - # - { path: ^/profile, roles: ROLE_USER } + - { path: ^/login$, role: PUBLIC_ACCESS } + - { path: ^/logout$, role: ROLE_USER } + - { path: ^/register, role: ROLE_ADMIN } + - { path: ^/admin, role: ROLE_ADMIN } + + - { path: ^/, role: ROLE_USER } when@test: security: diff --git a/config/packages/validator.yaml b/config/packages/validator.yaml new file mode 100644 index 0000000..0201281 --- /dev/null +++ b/config/packages/validator.yaml @@ -0,0 +1,13 @@ +framework: + validation: + email_validation_mode: html5 + + # Enables validator auto-mapping support. + # For instance, basic validation constraints will be inferred from Doctrine's metadata. + #auto_mapping: + # App\Entity\: [] + +when@test: + framework: + validation: + not_compromised_password: false diff --git a/config/packages/web_profiler.yaml b/config/packages/web_profiler.yaml new file mode 100644 index 0000000..b946111 --- /dev/null +++ b/config/packages/web_profiler.yaml @@ -0,0 +1,17 @@ +when@dev: + web_profiler: + toolbar: true + intercept_redirects: false + + framework: + profiler: + only_exceptions: false + collect_serializer_data: true + +when@test: + web_profiler: + toolbar: false + intercept_redirects: false + + framework: + profiler: { collect: false } diff --git a/config/routes/web_profiler.yaml b/config/routes/web_profiler.yaml new file mode 100644 index 0000000..8d85319 --- /dev/null +++ b/config/routes/web_profiler.yaml @@ -0,0 +1,8 @@ +when@dev: + web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + prefix: /_wdt + + web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + prefix: /_profiler diff --git a/config/services.yaml b/config/services.yaml index 2d6a76f..5268342 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -20,5 +20,6 @@ services: - '../src/Entity/' - '../src/Kernel.php' - # add more service definitions when explicit configuration is needed - # please note that last definitions always *replace* previous ones + App\Service\LastRelease: + arguments: + - '%kernel.project_dir%/release.json' diff --git a/deploy.php b/deploy.php new file mode 100644 index 0000000..fa4513c --- /dev/null +++ b/deploy.php @@ -0,0 +1,108 @@ +setRemoteUser('www-data') + ->set('branch', function () { + return input()->getOption('branch') ?: 'develop'; + }) + ->set('deploy_path', '~/snips.loken.nl'); + +set('bin/console', function () { + return parse('{{release_path}}/bin/console'); +}); + +set('console_options', function () { + return '--no-interaction'; +}); + +desc('Clear cache'); +task('cache:clear', function () { + run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup'); +}); + +desc('Warm up cache'); +task('cache:warmup', function () { + run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}'); +}); + +desc('Migrate database'); +task('database:migrate', function () { +// $options = '--allow-no-migration'; +// if (get('migrations_config') !== '') { +// $options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options); +// } +// +// run(sprintf('{{bin/php}} {{bin/console}} doctrine:migrations:migrate %s {{console_options}}', $options)); + run('{{bin/php}} {{bin/console}} doctrine:schema:update --force'); +}); + +task('deployment:log', function () { //https://stackoverflow.com/questions/59686270/how-to-log-deployments-in-deployer + $branch = parse('{{branch}}'); + $date = date('Y-m-d H:i:s'); + $commitHashShort = runLocally('git rev-parse --short HEAD'); +// $commitHash = runLocally('git rev-parse HEAD'); + $commit = explode(PHP_EOL, runLocally('git log -1 --pretty="%H%n%ci"')); + $commitHash = $commit[0]; + $commitDate = $commit[1]; + +// $line = sprintf('%s %s branch="%s" hash="%s"', $date, $commitHashShort, $branch, $commitHash); + $projectUrlBase = 'https://git.loken.nl/ardent/AnimeRSS4'; + $array = [ + 'branch' => $branch, + 'branchUrl' => sprintf('%s/src/branch/%s', $projectUrlBase, $branch), + 'date' => $date, + 'commitHashShort' => $commitHashShort, + 'commitHashLong' => $commitHash, + 'commitDate' => $commitDate, + 'commitUrl' => sprintf('%s/commit/%s', $projectUrlBase, $commitHash), + 'projectUrl' => $projectUrlBase, + ]; + $json = json_encode($array, JSON_PRETTY_PRINT); + + runLocally("echo '$json' > release.json"); + upload('release.json', '{{release_path}}/release.json'); +}); + +//desc('Deploy project'); +//task('deploy', [ +// 'deployment:log', +//]); + +desc('Deploy project'); +task('deploy', [ + 'deploy:prepare', + 'deploy:vendors', + 'cache:clear', + 'cache:warmup', + 'database:migrate', + 'deployment:log', + 'deploy:symlink', + 'deploy:unlock', + 'deploy:cleanup', +]); + +after('deploy', 'deploy:success'); + +// [Optional] if deploy fails automatically unlock. +after('deploy:failed', 'deploy:unlock'); diff --git a/src/Controller/.gitignore b/src/Controller/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php new file mode 100644 index 0000000..8bab2e8 --- /dev/null +++ b/src/Controller/HomeController.php @@ -0,0 +1,19 @@ +redirectToRoute('task_view'); +// return $this->render('simple.html.twig', [ +// 'text' => 'Welcome!' +// ]); + } +} \ No newline at end of file diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php new file mode 100644 index 0000000..81d0e4e --- /dev/null +++ b/src/Controller/SecurityController.php @@ -0,0 +1,72 @@ +getLastAuthenticationError(); + $lastUsername = $authenticationUtils->getLastUsername(); + + return $this->render('security/login.html.twig', [ + 'last_username' => $lastUsername, + 'error' => $error, + ]); + } + + #[Route('/logout', name: 'logout')] + public function logout(): void + { + // controller can be blank: it will never be called! + throw new Exception('Don\'t forget to activate logout in security.yaml'); + } + + #[Route('/register', name: 'register')] + public function register( + Request $request, + UserPasswordHasherInterface $userPasswordHasher, + EntityManagerInterface $entityManager, + ): Response + { + $user = new User(); + $form = $this->createForm(RegistrationFormType::class, $user); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + if ($form->get('plainPassword')->getData() !== $form->get('plainPasswordRepeated')->getData()) { + $this->addFlash('error', 'Password and password repeated must be the same'); + } else { + $user->setPassword( + $userPasswordHasher->hashPassword( + $user, + $form->get('plainPassword')->getData() + ) + ); + + $entityManager->persist($user); + $entityManager->flush(); + // do anything else you need here, like send an email + $this->addFlash('success', sprintf('Successfully registered user %s', $user->getUsername())); + + return $this->redirectToRoute('register'); + } + } + + return $this->render('security/register.html.twig', [ + 'registrationForm' => $form->createView(), + ]); + } +} diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php new file mode 100644 index 0000000..6935079 --- /dev/null +++ b/src/Controller/UserController.php @@ -0,0 +1,63 @@ +getUser(); + $form = $this->createForm(ProfileType::class, $user); + + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + if (!empty($form->get('plainPassword')->getData())) { + if ($form->get('plainPassword')->getData() !== $form->get('plainPasswordRepeated')->getData()) { + $this->addFlash('error', 'Password and password repeated must be the same, password not changed'); + } else { + $this->addFlash('success', 'Password updated successfully'); + $user + ->setPassword( + $userPasswordHasher->hashPassword( + $user, + $form->get('plainPassword')->getData() + ) + ); + } + } + $this->addFlash('success', 'Profile updated successfully'); + + $this->em->persist($user); + $this->em->flush(); + } + + return $this->render('user/profile.html.twig', [ + 'form' => $form->createView(), + 'release' => $lastRelease, + ]); + } +} \ No newline at end of file diff --git a/src/Form/ProfileType.php b/src/Form/ProfileType.php new file mode 100644 index 0000000..6cfced5 --- /dev/null +++ b/src/Form/ProfileType.php @@ -0,0 +1,49 @@ +add('email') + ->add('plainPassword', PasswordType::class, [ + 'required' => false, + 'mapped' => false, + 'attr' => ['autocomplete' => 'new-password'], + 'label' => 'Password', + 'constraints' => [ + new Length([ + 'min' => 8, + 'minMessage' => 'Your password should be at least {{ limit }} characters', + // max length allowed by Symfony for security reasons + 'max' => 4096, + ]), + ], + ]) + ->add('plainPasswordRepeated', PasswordType::class, [ + 'required' => false, + 'mapped' => false, + 'attr' => ['autocomplete' => 'new-password'], + 'label' => 'Password repeated', + ]) + ->add('save', SubmitType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => User::class, + ]); + } +} diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php new file mode 100644 index 0000000..2cafa11 --- /dev/null +++ b/src/Form/RegistrationFormType.php @@ -0,0 +1,64 @@ +add('username') + ->add('name') + ->add('plainPassword', PasswordType::class, [ + // instead of being set onto the object directly, + // this is read and encoded in the controller + 'mapped' => false, + 'attr' => ['autocomplete' => 'new-password'], + 'label' => 'Password', + 'constraints' => [ + new NotBlank([ + 'message' => 'Please enter a password', + ]), + new Length([ + 'min' => 8, + 'minMessage' => 'Your password should be at least {{ limit }} characters', + // max length allowed by Symfony for security reasons + 'max' => 4096, + ]), + ], + ]) + ->add('plainPasswordRepeated', PasswordType::class, [ + 'mapped' => false, + 'label' => 'Password repeated', + ]) + ->add('email', EmailType::class) +// ->add('agreeTerms', CheckboxType::class, [ +// 'mapped' => false, +// 'constraints' => [ +// new IsTrue([ +// 'message' => 'You should agree to our terms.', +// ]), +// ], +// ]) + ->add('register', SubmitType::class); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => User::class, + ]); + } +} \ No newline at end of file diff --git a/src/Service/LastRelease.php b/src/Service/LastRelease.php new file mode 100644 index 0000000..29eb492 --- /dev/null +++ b/src/Service/LastRelease.php @@ -0,0 +1,68 @@ + "string", + "date" => "string", + "commitHashShort" => "string", + "commitHashLong" => "string", + "commitDate" => "string", + "branchUrl" => "string", + "projectUrl" => "string", + "commitUrl" => "string", + ])] + private array $lastRelease = []; + + public function __construct(string $jsonFile) + { + if (file_exists($jsonFile)) { + $this->lastRelease = json_decode(file_get_contents($jsonFile), true); + } + } + + public function getBranch(): string + { + return $this->lastRelease['branch'] ?? '-'; + } + + public function getBranchUrl(): string + { + return $this->lastRelease['branchUrl'] ?? '#'; + } + + public function getProjectUrl(): string + { + return $this->lastRelease['projectUrl'] ?? '#'; + } + + public function getCommitUrl(): string + { + return $this->lastRelease['commitUrl'] ?? '#'; + } + + public function getDate(): string + { + return $this->lastRelease['date'] ?? '-'; + } + + public function getCommitHashShort(): string + { + return $this->lastRelease['commitHashShort'] ?? '-'; + } + + public function getCommitHashLong(): string + { + return $this->lastRelease['commitHashLong'] ?? '-'; + } + + public function getCommitDate(): string + { + return $this->lastRelease['commitDate'] ?? '-'; + } + +} \ No newline at end of file diff --git a/symfony.lock b/symfony.lock index f8f707a..0ae6795 100644 --- a/symfony.lock +++ b/symfony.lock @@ -38,6 +38,18 @@ "bin/console" ] }, + "symfony/debug-bundle": { + "version": "6.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "5aa8aa48234c8eb6dbdd7b3cd5d791485d2cec4b" + }, + "files": [ + "config/packages/debug.yaml" + ] + }, "symfony/flex": { "version": "2.2", "recipe": { @@ -78,6 +90,18 @@ "ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f" } }, + "symfony/monolog-bundle": { + "version": "3.8", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.7", + "ref": "213676c4ec929f046dfde5ea8e97625b81bc0578" + }, + "files": [ + "config/packages/monolog.yaml" + ] + }, "symfony/routing": { "version": "6.2", "recipe": { @@ -116,6 +140,31 @@ "templates/base.html.twig" ] }, + "symfony/validator": { + "version": "6.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "c32cfd98f714894c4f128bb99aa2530c1227603c" + }, + "files": [ + "config/packages/validator.yaml" + ] + }, + "symfony/web-profiler-bundle": { + "version": "6.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.1", + "ref": "e42b3f0177df239add25373083a564e5ead4e13a" + }, + "files": [ + "config/packages/web_profiler.yaml", + "config/routes/web_profiler.yaml" + ] + }, "twig/extra-bundle": { "version": "v3.5.1" } diff --git a/templates/base.html.twig b/templates/base.html.twig deleted file mode 100644 index d4f83f7..0000000 --- a/templates/base.html.twig +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {% block title %}Welcome!{% endblock %} - - {# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #} - {% block stylesheets %} - {{ encore_entry_link_tags('app') }} - {% endblock %} - - {% block javascripts %} - {{ encore_entry_script_tags('app') }} - {% endblock %} - - - {% block body %}{% endblock %} - - diff --git a/templates/base/base.html.twig b/templates/base/base.html.twig new file mode 100644 index 0000000..3bff21d --- /dev/null +++ b/templates/base/base.html.twig @@ -0,0 +1,70 @@ + + + + + + {% block title %}BLES{% endblock %} + + + {% if chartjs|default(false) %} + + + {% endif %} + + {% block css %} + + {% endblock %} + + +{{ include('base/navbar.html.twig') }} + +{# alert block #} +
+
+
+
+ {% block flashes %} + {% for msg in app.session.flashBag.get('error') %} + + {% endfor %} + {% for msg in app.session.flashBag.get('success') %} +
+ Success: {{ msg|raw }} +
+ {% endfor %} + {% endblock %} +
+
+
+ +{# body blocks #} +{% block bodyraw %} +
+
+
+ {% block body %}{% endblock %} +
+ {% if block('body2') is defined %} +
+ {{ block('body2') }} +
+ {% endif %} +
+
+{% endblock %} + +{# javascript block #} +{% block js %} + + +{% endblock %} + + \ No newline at end of file diff --git a/templates/base/navbar.html.twig b/templates/base/navbar.html.twig new file mode 100644 index 0000000..b68a61e --- /dev/null +++ b/templates/base/navbar.html.twig @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig new file mode 100644 index 0000000..53f81fb --- /dev/null +++ b/templates/security/login.html.twig @@ -0,0 +1,32 @@ +{% extends 'base/base.html.twig' %} + +{% block title %}Login{% endblock %} + +{% block body %} +
+ {% if error %} +
{{ error.messageKey|trans(error.messageData, 'security') }}
+ {% endif %} + {% if app.user %} +
+ You are already logged in as {{ app.user }}, Logout +
+ {% endif %} +

Please login

+ + +
+ + + +
+ +
+ +
+ +
+{% endblock %} diff --git a/templates/security/register.html.twig b/templates/security/register.html.twig new file mode 100644 index 0000000..0036da8 --- /dev/null +++ b/templates/security/register.html.twig @@ -0,0 +1,6 @@ +{% extends 'base/base.html.twig' %} + +{% block body %} +

Register new user

+ {{ form(registrationForm) }} +{% endblock %} \ No newline at end of file diff --git a/templates/simple.html.twig b/templates/simple.html.twig new file mode 100644 index 0000000..3039167 --- /dev/null +++ b/templates/simple.html.twig @@ -0,0 +1,5 @@ +{% extends 'base/base.html.twig' %} + +{% block body %} + {{ text | nl2br }} +{% endblock %} \ No newline at end of file diff --git a/templates/user/profile.html.twig b/templates/user/profile.html.twig new file mode 100644 index 0000000..b262e5d --- /dev/null +++ b/templates/user/profile.html.twig @@ -0,0 +1,26 @@ +{% extends "base/base.html.twig" %} + +{% block body %} +
+
+

{{ app.user.name }}

+ {% if is_granted('ROLE_API') %} + Your api key: {{ app.user.apiKey }} Regenerate
+ {% endif %} +
+ {% if is_granted('ROLE_ADMIN') %} +

+

Latest release stats

+ Branch: {{ release.branch }}
+ Date: {{ release.date }}
+ Hash short: {{ release.commitHashShort }}
+ Hash long: {{ release.commitHashLong }}
+ Commit date: {{ release.commitDate }}
+ {% endif %} +
+
+

Change profile

+ {{ form(form) }} +
+
+{% endblock %} \ No newline at end of file