Create user model #10
|
@ -1,35 +1,36 @@
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "PHP 8.0",
|
"name": "PHP 8.0",
|
||||||
"type": "php",
|
"type": "php",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"pathMappings": {
|
"pathMappings": {
|
||||||
"/web/backend": "${workspaceFolder}\\src\\backend"
|
"/web/backend": "${workspaceFolder}\\src\\backend"
|
||||||
},
|
},
|
||||||
"skipFiles": [
|
"skipFiles": [
|
||||||
"${workspaceFolder}/src/backend/vendor/**"
|
"${workspaceFolder}/src/backend/vendor/",
|
||||||
],
|
"/web/backend/vendor/"
|
||||||
"port": 7780,
|
],
|
||||||
"hostname": "127.0.0.1",
|
"port": 7780,
|
||||||
"xdebugSettings": {
|
"hostname": "127.0.0.1",
|
||||||
"max_children": 100,
|
"xdebugSettings": {
|
||||||
}
|
"max_children": 100,
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
"name": "PHP 8.0 with vendor",
|
{
|
||||||
"type": "php",
|
"name": "PHP 8.0 with vendor",
|
||||||
"request": "launch",
|
"type": "php",
|
||||||
"pathMappings": {
|
"request": "launch",
|
||||||
"/web/backend": "${workspaceFolder}\\src\\backend"
|
"pathMappings": {
|
||||||
},
|
"/web/backend": "${workspaceFolder}\\src\\backend"
|
||||||
"port": 7780,
|
},
|
||||||
"hostname": "127.0.0.1",
|
"port": 7780,
|
||||||
"xdebugSettings": {
|
"hostname": "127.0.0.1",
|
||||||
"max_children": 100,
|
"xdebugSettings": {
|
||||||
}
|
"max_children": 100,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -1 +1 @@
|
||||||
docker compose -p curenet up
|
docker.exe compose -p curenet up
|
||||||
|
|
|
@ -34,11 +34,12 @@ echo "> Configure database"
|
||||||
|
|
||||||
echo "> Configure symfony"
|
echo "> Configure symfony"
|
||||||
cd /web/backend
|
cd /web/backend
|
||||||
composer install
|
composer install
|
||||||
|
php bin/console doctrine:schema:update --force
|
||||||
|
|
||||||
echo "> Configure angular"
|
echo "> Configure angular"
|
||||||
cd /web/frontend
|
cd /web/frontend
|
||||||
npm i
|
npm ci
|
||||||
|
|
||||||
echo "> Starting angular"
|
echo "> Starting angular"
|
||||||
ng serve
|
ng serve
|
||||||
|
|
|
@ -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()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
Loading…
Reference in New Issue