Compare commits
No commits in common. "a949b7b3901482c704c511b45c0eaa718c1e47ff" and "e9c7395d867d405a3394dba21884962fb7feee8a" have entirely different histories.
a949b7b390
...
e9c7395d86
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,4 +23,3 @@
|
|||||||
/public/assets/
|
/public/assets/
|
||||||
/assets/vendor/
|
/assets/vendor/
|
||||||
###< symfony/asset-mapper ###
|
###< symfony/asset-mapper ###
|
||||||
./idea
|
|
8
.idea/.gitignore
vendored
8
.idea/.gitignore
vendored
@ -1,8 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
@ -4,18 +4,14 @@ security:
|
|||||||
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
||||||
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
||||||
providers:
|
providers:
|
||||||
# used to reload user from session & other features (e.g. switch_user)
|
users_in_memory: { memory: null }
|
||||||
app_user_provider:
|
|
||||||
entity:
|
|
||||||
class: App\Entity\User
|
|
||||||
property: nickname
|
|
||||||
firewalls:
|
firewalls:
|
||||||
dev:
|
dev:
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
security: false
|
security: false
|
||||||
main:
|
main:
|
||||||
lazy: true
|
lazy: true
|
||||||
provider: app_user_provider
|
provider: users_in_memory
|
||||||
|
|
||||||
# activate different ways to authenticate
|
# activate different ways to authenticate
|
||||||
# https://symfony.com/doc/current/security.html#the-firewall
|
# https://symfony.com/doc/current/security.html#the-firewall
|
||||||
|
@ -1,186 +0,0 @@
|
|||||||
<?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`')]
|
|
||||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_NICKNAME', fields: ['nickname'])]
|
|
||||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
|
||||||
private ?string $nickname = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var list<string> The user roles
|
|
||||||
*/
|
|
||||||
#[ORM\Column]
|
|
||||||
private array $roles = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string The hashed password
|
|
||||||
*/
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?string $password = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $firstName = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $lastName = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $tel = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $address = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $mail = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNickname(): ?string
|
|
||||||
{
|
|
||||||
return $this->nickname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNickname(string $nickname): static
|
|
||||||
{
|
|
||||||
$this->nickname = $nickname;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A visual identifier that represents this user.
|
|
||||||
*
|
|
||||||
* @see UserInterface
|
|
||||||
*/
|
|
||||||
public function getUserIdentifier(): string
|
|
||||||
{
|
|
||||||
return (string) $this->nickname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UserInterface
|
|
||||||
*
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getRoles(): array
|
|
||||||
{
|
|
||||||
$roles = $this->roles;
|
|
||||||
// guarantee every user at least has ROLE_USER
|
|
||||||
$roles[] = 'ROLE_USER';
|
|
||||||
|
|
||||||
return array_unique($roles);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param list<string> $roles
|
|
||||||
*/
|
|
||||||
public function setRoles(array $roles): static
|
|
||||||
{
|
|
||||||
$this->roles = $roles;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PasswordAuthenticatedUserInterface
|
|
||||||
*/
|
|
||||||
public function getPassword(): ?string
|
|
||||||
{
|
|
||||||
return $this->password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPassword(string $password): static
|
|
||||||
{
|
|
||||||
$this->password = $password;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UserInterface
|
|
||||||
*/
|
|
||||||
public function eraseCredentials(): void
|
|
||||||
{
|
|
||||||
// If you store any temporary, sensitive data on the user, clear it here
|
|
||||||
// $this->plainPassword = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFirstName(): ?string
|
|
||||||
{
|
|
||||||
return $this->firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFirstName(string $firstName): static
|
|
||||||
{
|
|
||||||
$this->firstName = $firstName;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLastName(): ?string
|
|
||||||
{
|
|
||||||
return $this->lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLastName(string $lastName): static
|
|
||||||
{
|
|
||||||
$this->lastName = $lastName;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTel(): ?string
|
|
||||||
{
|
|
||||||
return $this->tel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTel(string $tel): static
|
|
||||||
{
|
|
||||||
$this->tel = $tel;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAddress(): ?string
|
|
||||||
{
|
|
||||||
return $this->address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAddress(string $address): static
|
|
||||||
{
|
|
||||||
$this->address = $address;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMail(): ?string
|
|
||||||
{
|
|
||||||
return $this->mail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setMail(string $mail): static
|
|
||||||
{
|
|
||||||
$this->mail = $mail;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
|||||||
<?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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends ServiceEntityRepository<User>
|
|
||||||
*/
|
|
||||||
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.', $user::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->setPassword($newHashedPassword);
|
|
||||||
$this->getEntityManager()->persist($user);
|
|
||||||
$this->getEntityManager()->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return User[] Returns an array of User objects
|
|
||||||
// */
|
|
||||||
// public function findByExampleField($value): array
|
|
||||||
// {
|
|
||||||
// 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
Block a user