Merge branch 'dev' into 6-update-documentation
This commit is contained in:
commit
42af60cfc8
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "PHP 8.0",
|
||||||
|
"type": "php",
|
||||||
|
"request": "launch",
|
||||||
|
"pathMappings": {
|
||||||
|
"/web/backend": "${workspaceFolder}\\src\\backend"
|
||||||
|
},
|
||||||
|
"skipFiles": [
|
||||||
|
"${workspaceFolder}/src/backend/vendor/",
|
||||||
|
"/web/backend/vendor/"
|
||||||
|
],
|
||||||
|
"port": 7780,
|
||||||
|
"hostname": "127.0.0.1",
|
||||||
|
"xdebugSettings": {
|
||||||
|
"max_children": 100,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PHP 8.0 with vendor",
|
||||||
|
"type": "php",
|
||||||
|
"request": "launch",
|
||||||
|
"pathMappings": {
|
||||||
|
"/web/backend": "${workspaceFolder}\\src\\backend"
|
||||||
|
},
|
||||||
|
"port": 7780,
|
||||||
|
"hostname": "127.0.0.1",
|
||||||
|
"xdebugSettings": {
|
||||||
|
"max_children": 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
logs/*
|
||||||
|
!logs/.gitkeep
|
||||||
|
cache/*/*
|
||||||
|
!cache/*/.gitkeep
|
|
@ -0,0 +1,50 @@
|
||||||
|
FROM debian:10
|
||||||
|
|
||||||
|
RUN apt update \
|
||||||
|
&& echo "Binary::apt::APT::Keep-Downloaded-Packages \"true\";" | tee /etc/apt/apt.conf.d/01keep-debs \
|
||||||
|
&& apt install -y wget lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 gcc g++ make \
|
||||||
|
&& echo "configure repos" \
|
||||||
|
&& echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list \
|
||||||
|
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/postgresql.list \
|
||||||
|
&& echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/buster pgadmin4 main" | tee /etc/apt/sources.list.d/pgdg.list \
|
||||||
|
&& echo "download keys" \
|
||||||
|
&& (wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add - ) \
|
||||||
|
&& (wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - ) \
|
||||||
|
&& (wget -qO - https://www.pgadmin.org/static/packages_pgadmin_org.pub | apt-key add - ) \
|
||||||
|
&& echo "install nodejs" \
|
||||||
|
&& wget -qO - https://deb.nodesource.com/setup_16.x | bash - \
|
||||||
|
&& echo "update repos" \
|
||||||
|
&& apt update \
|
||||||
|
&& echo "install software" \
|
||||||
|
&& apt install -y aptitude unzip \
|
||||||
|
&& apt install -y postgresql pgadmin4 \
|
||||||
|
&& apt install -y php8.0 php8.0-ctype php8.0-iconv php8.0-simplexml php8.0-tokenizer php8.0-fpm php8.0-pdo php8.0-pdo-pgsql php8.0-pgsql php8.0-mbstring php8.0-zip php8.0-xdebug \
|
||||||
|
&& apt install -y nginx \
|
||||||
|
&& apt install -y nodejs \
|
||||||
|
&& echo "configure tools" \
|
||||||
|
&& echo "# angular" \
|
||||||
|
&& npm install -g @angular/cli \
|
||||||
|
&& echo "# composer" \
|
||||||
|
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
|
||||||
|
&& php composer-setup.php --install-dir=/usr/local/bin/ --filename=composer \
|
||||||
|
&& php -r "unlink('composer-setup.php');" \
|
||||||
|
&& echo "# nginx" \
|
||||||
|
&& ln -s /web/config/nginx/app.conf /etc/nginx/conf.d/app.conf \
|
||||||
|
&& ln -s /web/config/nginx/php80.conf /etc/nginx/php80.conf \
|
||||||
|
&& echo "# postgresql" \
|
||||||
|
&& echo "postgres:WeryStronkPaz2" | chpasswd \
|
||||||
|
&& echo "# pgadmin4" \
|
||||||
|
&& bash -c 'PGADMIN_SETUP_EMAIL="admin@pgadmin.localhost" PGADMIN_SETUP_PASSWORD="WeryStronkPaz2" /usr/pgadmin4/bin/setup-web.sh --yes' \
|
||||||
|
&& echo "" > /etc/nginx/sites-enabled/default \
|
||||||
|
&& echo "!!! DONE !!!"
|
||||||
|
|
||||||
|
RUN apt install -y nano openssh-server telnet
|
||||||
|
VOLUME /web/backend/vendor
|
||||||
|
VOLUME /web/backend/var
|
||||||
|
VOLUME /web/frontend/node_modules
|
||||||
|
|
||||||
|
EXPOSE 7700 7780 7781
|
||||||
|
|
||||||
|
STOPSIGNAL SIGQUIT
|
||||||
|
|
||||||
|
CMD ["bash", "/web/config/startup.sh"]
|
|
@ -0,0 +1,22 @@
|
||||||
|
version: "3.9"
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- 7700:7700
|
||||||
|
expose:
|
||||||
|
- 7780:7780
|
||||||
|
- 7781:7781
|
||||||
|
volumes:
|
||||||
|
- .:/web/config
|
||||||
|
- ../src/backend:/web/backend:cached
|
||||||
|
- ../src/frontend:/web/frontend:cached
|
||||||
|
- ./logs:/var/log
|
||||||
|
- vendor:/web/backend/vendor
|
||||||
|
- var:/web/backend/var
|
||||||
|
- nodemodules:/web/frontend/node_modules
|
||||||
|
volumes:
|
||||||
|
nodemodules:
|
||||||
|
vendor:
|
||||||
|
var:
|
||||||
|
nodemodules:
|
|
@ -0,0 +1,27 @@
|
||||||
|
server {
|
||||||
|
server_name localhost;
|
||||||
|
listen 7700;
|
||||||
|
root /web/backend/public;
|
||||||
|
index index.htm index.html index.php;
|
||||||
|
location / {
|
||||||
|
proxy_bind 127.0.0.1;
|
||||||
|
proxy_pass http://localhost:4200;
|
||||||
|
}
|
||||||
|
location /api/ {
|
||||||
|
try_files $uri $uri/ /index.php/$uri?$query_string;
|
||||||
|
}
|
||||||
|
location /coverage/ {
|
||||||
|
alias /web/coverage/html-coverage/;
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
location /pgadmin4/ {
|
||||||
|
include proxy_params;
|
||||||
|
proxy_bind 127.0.0.1;
|
||||||
|
proxy_pass http://localhost:80;
|
||||||
|
proxy_set_header X-Script-Name /pgadmin4;
|
||||||
|
}
|
||||||
|
proxy_intercept_errors on;
|
||||||
|
fastcgi_intercept_errors on;
|
||||||
|
fastcgi_hide_header X-Powered-By;
|
||||||
|
include "php80.conf";
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
include snippets/fastcgi-php.conf;
|
||||||
|
location ~ [^/]\.php(/|$) {
|
||||||
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
|
if (!-f $document_root$fastcgi_script_name) {
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
fastcgi_param HTTP_PROXY "";
|
||||||
|
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_buffering off;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
zend_extension=xdebug.so
|
||||||
|
|
||||||
|
[xdebug]
|
||||||
|
xdebug.mode=coverage
|
||||||
|
xdebug.start_with_request=yes
|
||||||
|
xdebug.client_host=host.docker.internal
|
||||||
|
xdebug.client_port=7781
|
||||||
|
|
||||||
|
xdebug.show_exception_trace = 1
|
||||||
|
xdebug.show_error_trace = 1
|
||||||
|
|
||||||
|
xdebug.log_level = 0
|
|
@ -0,0 +1,12 @@
|
||||||
|
zend_extension=xdebug.so
|
||||||
|
|
||||||
|
[xdebug]
|
||||||
|
xdebug.mode=debug
|
||||||
|
xdebug.start_with_request=yes
|
||||||
|
xdebug.client_host=host.docker.internal
|
||||||
|
xdebug.client_port=7780
|
||||||
|
|
||||||
|
xdebug.show_exception_trace = 1
|
||||||
|
xdebug.show_error_trace = 1
|
||||||
|
|
||||||
|
xdebug.log_level = 0
|
|
@ -0,0 +1,4 @@
|
||||||
|
ALTER USER postgres WITH PASSWORD 'WeryStronkPaz2';
|
||||||
|
CREATE USER curenet WITH PASSWORD 'WeryStronkPaz2';
|
||||||
|
CREATE DATABASE curenet;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE curenet to curenet;
|
|
@ -0,0 +1 @@
|
||||||
|
docker.exe compose -p curenet up
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "> Configure logs"
|
||||||
|
mkdir -p /var/log/{apache2,nginx,pgadmin,postgresql}
|
||||||
|
chown postgres:adm /var/log/postgresql -R
|
||||||
|
chown root:postgres /var/log/postgresql
|
||||||
|
|
||||||
|
echo "> Configure volumes"
|
||||||
|
[ -e /web/frontend/node_modules ] || ln -s /web/node /web/frontend/node_modules
|
||||||
|
[ -e /web/backend/var ] || ln -s /web/var /web/backend/var
|
||||||
|
[ -e /web/backend/vendor ] || ln -s /web/vendor /web/backend/vendor
|
||||||
|
|
||||||
|
echo "> Starting php8.0-fpm server"
|
||||||
|
[ -e /etc/php/8.0/fpm/conf.d/20-xdebug.ini ] && rm /etc/php/8.0/fpm/conf.d/20-xdebug.ini || echo OK
|
||||||
|
[ -e /etc/php/8.0/cli/conf.d/20-xdebug.ini ] && rm /etc/php/8.0/cli/conf.d/20-xdebug.ini || echo OK
|
||||||
|
cp /web/config/php8.0/xdebug-fpm.ini /etc/php/8.0/fpm/conf.d/20-xdebug.ini
|
||||||
|
cp /web/config/php8.0/xdebug-cli.ini /etc/php/8.0/cli/conf.d/20-xdebug.ini
|
||||||
|
service php8.0-fpm start
|
||||||
|
|
||||||
|
echo "> Starting nginx server"
|
||||||
|
service nginx start
|
||||||
|
|
||||||
|
echo "> Starting apache2 server for pgAdmin4"
|
||||||
|
service apache2 start
|
||||||
|
|
||||||
|
echo "> Starting postgresql database"
|
||||||
|
service postgresql start
|
||||||
|
|
||||||
|
echo "> Starting ssh server"
|
||||||
|
service ssh start
|
||||||
|
|
||||||
|
echo "> Configure database"
|
||||||
|
su postgres -c psql postgres < /web/config/postgres/init-data.sql
|
||||||
|
|
||||||
|
echo "> Configure symfony"
|
||||||
|
cd /web/backend
|
||||||
|
composer install
|
||||||
|
php bin/console doctrine:schema:update --force
|
||||||
|
|
||||||
|
echo "> Configure angular"
|
||||||
|
cd /web/frontend
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
echo "> Starting angular"
|
||||||
|
ng serve
|
|
@ -0,0 +1,3 @@
|
||||||
|
APP_ENV=dev
|
||||||
|
APP_SECRET=0fc8d6b67b9f1100b3eb3e3c80d36fda
|
||||||
|
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
|
|
@ -0,0 +1,3 @@
|
||||||
|
APP_ENV=dev
|
||||||
|
APP_SECRET=0fc8d6b67b9f1100b3eb3e3c80d36fda
|
||||||
|
DATABASE_URL="postgresql://curenet:WeryStronkPaz2@127.0.0.1:5432/curenet?serverVersion=13&charset=utf8"
|
|
@ -0,0 +1,3 @@
|
||||||
|
APP_ENV=dev
|
||||||
|
APP_SECRET=0fc8d6b67b9f1100b3eb3e3c80d36fda
|
||||||
|
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
|
|
@ -1,100 +1,100 @@
|
||||||
{
|
{
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.2.5",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
"composer/package-versions-deprecated": "1.11.99.2",
|
"composer/package-versions-deprecated": "1.11.99.2",
|
||||||
"doctrine/annotations": "^1.0",
|
"doctrine/annotations": "^1.0",
|
||||||
"doctrine/doctrine-bundle": "^2.4",
|
"doctrine/doctrine-bundle": "^2.4",
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.1",
|
"doctrine/doctrine-migrations-bundle": "^3.1",
|
||||||
"doctrine/orm": "^2.9",
|
"doctrine/orm": "^2.9",
|
||||||
"phpdocumentor/reflection-docblock": "^5.2",
|
"phpdocumentor/reflection-docblock": "^5.2",
|
||||||
"sensio/framework-extra-bundle": "^6.1",
|
"sensio/framework-extra-bundle": "^6.1",
|
||||||
"symfony/asset": "5.3.*",
|
"symfony/asset": "5.3.*",
|
||||||
"symfony/console": "5.3.*",
|
"symfony/console": "5.3.*",
|
||||||
"symfony/dotenv": "5.3.*",
|
"symfony/dotenv": "5.3.*",
|
||||||
"symfony/expression-language": "5.3.*",
|
"symfony/expression-language": "5.3.*",
|
||||||
"symfony/flex": "^1.3.1",
|
"symfony/flex": "^1.3.1",
|
||||||
"symfony/form": "5.3.*",
|
"symfony/form": "5.3.*",
|
||||||
"symfony/framework-bundle": "5.3.*",
|
"symfony/framework-bundle": "5.3.*",
|
||||||
"symfony/http-client": "5.3.*",
|
"symfony/http-client": "5.3.*",
|
||||||
"symfony/intl": "5.3.*",
|
"symfony/intl": "5.3.*",
|
||||||
"symfony/mailer": "5.3.*",
|
"symfony/mailer": "5.3.*",
|
||||||
"symfony/mime": "5.3.*",
|
"symfony/mime": "5.3.*",
|
||||||
"symfony/monolog-bundle": "^3.1",
|
"symfony/monolog-bundle": "^3.1",
|
||||||
"symfony/notifier": "5.3.*",
|
"symfony/notifier": "5.3.*",
|
||||||
"symfony/process": "5.3.*",
|
"symfony/process": "5.3.*",
|
||||||
"symfony/property-access": "5.3.*",
|
"symfony/property-access": "5.3.*",
|
||||||
"symfony/property-info": "5.3.*",
|
"symfony/property-info": "5.3.*",
|
||||||
"symfony/proxy-manager-bridge": "5.3.*",
|
"symfony/proxy-manager-bridge": "5.3.*",
|
||||||
"symfony/runtime": "5.3.*",
|
"symfony/runtime": "5.3.*",
|
||||||
"symfony/security-bundle": "5.3.*",
|
"symfony/security-bundle": "5.3.*",
|
||||||
"symfony/serializer": "5.3.*",
|
"symfony/serializer": "5.3.*",
|
||||||
"symfony/string": "5.3.*",
|
"symfony/string": "5.3.*",
|
||||||
"symfony/translation": "5.3.*",
|
"symfony/translation": "5.3.*",
|
||||||
"symfony/twig-bundle": "^5.3",
|
"symfony/twig-bundle": "^5.3",
|
||||||
"symfony/validator": "5.3.*",
|
"symfony/validator": "5.3.*",
|
||||||
"symfony/web-link": "5.3.*",
|
"symfony/web-link": "5.3.*",
|
||||||
"symfony/yaml": "5.3.*",
|
"symfony/yaml": "5.3.*",
|
||||||
"twig/extra-bundle": "^2.12|^3.0",
|
"twig/extra-bundle": "^2.12|^3.0",
|
||||||
"twig/twig": "^2.12|^3.0"
|
"twig/twig": "^2.12|^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^9.5",
|
||||||
"symfony/browser-kit": "^5.3",
|
"symfony/browser-kit": "^5.3",
|
||||||
"symfony/css-selector": "^5.3",
|
"symfony/css-selector": "^5.3",
|
||||||
"symfony/debug-bundle": "^5.3",
|
"symfony/debug-bundle": "^5.3",
|
||||||
"symfony/maker-bundle": "^1.0",
|
"symfony/maker-bundle": "^1.33",
|
||||||
"symfony/phpunit-bridge": "^5.3",
|
"symfony/phpunit-bridge": "^5.3",
|
||||||
"symfony/stopwatch": "^5.3",
|
"symfony/stopwatch": "^5.3",
|
||||||
"symfony/var-dumper": "^5.3",
|
"symfony/var-dumper": "^5.3",
|
||||||
"symfony/web-profiler-bundle": "^5.3"
|
"symfony/web-profiler-bundle": "^5.3"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"preferred-install": {
|
"preferred-install": {
|
||||||
"*": "dist"
|
"*": "dist"
|
||||||
},
|
},
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "src/"
|
"App\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\Tests\\": "tests/"
|
"App\\Tests\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"symfony/polyfill-ctype": "*",
|
"symfony/polyfill-ctype": "*",
|
||||||
"symfony/polyfill-iconv": "*",
|
"symfony/polyfill-iconv": "*",
|
||||||
"symfony/polyfill-php72": "*"
|
"symfony/polyfill-php72": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"auto-scripts": {
|
"auto-scripts": {
|
||||||
"cache:clear": "symfony-cmd",
|
"cache:clear": "symfony-cmd",
|
||||||
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
||||||
},
|
},
|
||||||
"post-install-cmd": [
|
"post-install-cmd": [
|
||||||
"@auto-scripts"
|
"@auto-scripts"
|
||||||
],
|
],
|
||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
"@auto-scripts"
|
"@auto-scripts"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/symfony": "*"
|
"symfony/symfony": "*"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"symfony": {
|
"symfony": {
|
||||||
"allow-contrib": false,
|
"allow-contrib": false,
|
||||||
"require": "5.3.*"
|
"require": "5.3.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,25 +1,37 @@
|
||||||
security:
|
security:
|
||||||
# https://symfony.com/doc/current/security/experimental_authenticators.html
|
# https://symfony.com/doc/current/security/experimental_authenticators.html
|
||||||
enable_authenticator_manager: true
|
enable_authenticator_manager: true
|
||||||
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
|
password_hashers:
|
||||||
providers:
|
App\Entity\User:
|
||||||
users_in_memory: { memory: null }
|
algorithm: auto
|
||||||
firewalls:
|
|
||||||
dev:
|
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
|
||||||
security: false
|
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
|
||||||
main:
|
providers:
|
||||||
lazy: true
|
# used to reload user from session & other features (e.g. switch_user)
|
||||||
provider: users_in_memory
|
app_user_provider:
|
||||||
|
entity:
|
||||||
# activate different ways to authenticate
|
class: App\Entity\User
|
||||||
# https://symfony.com/doc/current/security.html#firewalls-authentication
|
property: id
|
||||||
|
# used to reload user from session & other features (e.g. switch_user)
|
||||||
# https://symfony.com/doc/current/security/impersonating_user.html
|
# used to reload user from session & other features (e.g. switch_user)
|
||||||
# switch_user: true
|
firewalls:
|
||||||
|
dev:
|
||||||
# Easy way to control access for large sections of your site
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
# Note: Only the *first* access control that matches will be used
|
security: false
|
||||||
access_control:
|
main:
|
||||||
# - { path: ^/admin, roles: ROLE_ADMIN }
|
lazy: true
|
||||||
# - { path: ^/profile, roles: ROLE_USER }
|
provider: app_user_provider
|
||||||
|
|
||||||
|
# activate different ways to authenticate
|
||||||
|
# https://symfony.com/doc/current/security.html#firewalls-authentication
|
||||||
|
|
||||||
|
# https://symfony.com/doc/current/security/impersonating_user.html
|
||||||
|
# switch_user: true
|
||||||
|
|
||||||
|
# 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 }
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20210723170329 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
|
||||||
|
$this->addSql('DROP TABLE "user"');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20210723171757 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD email VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD name VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD surname VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD avatar VARCHAR(255) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD country VARCHAR(3) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE "user" ADD state VARCHAR(10) DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP email');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP name');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP surname');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP avatar');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP country');
|
||||||
|
$this->addSql('ALTER TABLE "user" DROP state');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,219 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\UserRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity(repositoryClass=UserRepository::class)
|
||||||
|
* @ORM\Table(name="`user`")
|
||||||
|
*/
|
||||||
|
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json")
|
||||||
|
*/
|
||||||
|
private $roles = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The hashed password
|
||||||
|
* @ORM\Column(type="string")
|
||||||
|
*/
|
||||||
|
private $password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255)
|
||||||
|
*/
|
||||||
|
private $email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255)
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255)
|
||||||
|
*/
|
||||||
|
private $surname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $avatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=3, nullable=true)
|
||||||
|
*/
|
||||||
|
private $country;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=10, nullable=true)
|
||||||
|
*/
|
||||||
|
private $state;
|
||||||
|
|
||||||
|
public function getId(): ?string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(string $id): self
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visual identifier that represents this user.
|
||||||
|
*
|
||||||
|
* @see UserInterface
|
||||||
|
*/
|
||||||
|
public function getUserIdentifier(): string
|
||||||
|
{
|
||||||
|
return (string) $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since Symfony 5.3, use getUserIdentifier instead
|
||||||
|
*/
|
||||||
|
public function getUsername(): string
|
||||||
|
{
|
||||||
|
return (string) $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see UserInterface
|
||||||
|
*/
|
||||||
|
public function getRoles(): array
|
||||||
|
{
|
||||||
|
$roles = $this->roles;
|
||||||
|
// guarantee every user at least has ROLE_USER
|
||||||
|
$roles[] = 'ROLE_USER';
|
||||||
|
|
||||||
|
return array_unique($roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRoles(array $roles): self
|
||||||
|
{
|
||||||
|
$this->roles = $roles;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PasswordAuthenticatedUserInterface
|
||||||
|
*/
|
||||||
|
public function getPassword(): string
|
||||||
|
{
|
||||||
|
return $this->password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPassword(string $password): self
|
||||||
|
{
|
||||||
|
$this->password = $password;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returning a salt is only needed, if you are not using a modern
|
||||||
|
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
|
||||||
|
*
|
||||||
|
* @see UserInterface
|
||||||
|
*/
|
||||||
|
public function getSalt(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see UserInterface
|
||||||
|
*/
|
||||||
|
public function eraseCredentials()
|
||||||
|
{
|
||||||
|
// If you store any temporary, sensitive data on the user, clear it here
|
||||||
|
// $this->plainPassword = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail(): ?string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail(string $email): self
|
||||||
|
{
|
||||||
|
$this->email = $email;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSurname(): ?string
|
||||||
|
{
|
||||||
|
return $this->surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSurname(string $surname): self
|
||||||
|
{
|
||||||
|
$this->surname = $surname;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAvatar(): ?string
|
||||||
|
{
|
||||||
|
return $this->avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAvatar(?string $avatar): self
|
||||||
|
{
|
||||||
|
$this->avatar = $avatar;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCountry(): ?string
|
||||||
|
{
|
||||||
|
return $this->country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCountry(?string $country): self
|
||||||
|
{
|
||||||
|
$this->country = $country;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getState(): ?string
|
||||||
|
{
|
||||||
|
return $this->state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setState(?string $state): self
|
||||||
|
{
|
||||||
|
$this->state = $state;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method User|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method User|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method User[] findAll()
|
||||||
|
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to upgrade (rehash) the user's password automatically over time.
|
||||||
|
*/
|
||||||
|
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
||||||
|
{
|
||||||
|
if (!$user instanceof User) {
|
||||||
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->setPassword($newHashedPassword);
|
||||||
|
$this->_em->persist($user);
|
||||||
|
$this->_em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return User[] Returns an array of User objects
|
||||||
|
// */
|
||||||
|
/*
|
||||||
|
public function findByExampleField($value)
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('u')
|
||||||
|
->andWhere('u.exampleField = :val')
|
||||||
|
->setParameter('val', $value)
|
||||||
|
->orderBy('u.id', 'ASC')
|
||||||
|
->setMaxResults(10)
|
||||||
|
->getQuery()
|
||||||
|
->getResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function findOneBySomeField($value): ?User
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('u')
|
||||||
|
->andWhere('u.exampleField = :val')
|
||||||
|
->setParameter('val', $value)
|
||||||
|
->getQuery()
|
||||||
|
->getOneOrNullResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
|
@ -38,7 +38,7 @@
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/frontend",
|
"outputPath": "dist",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"polyfills": "src/polyfills.ts",
|
"polyfills": "src/polyfills.ts",
|
||||||
|
|
Loading…
Reference in New Issue