Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppEntity;
- use DoctrineORMMapping as ORM;
- use SymfonyBridgeDoctrineValidatorConstraintsUniqueEntity;
- use SymfonyComponentSecurityCoreUserUserInterface;
- /**
- * @ORMEntity(repositoryClass="AppRepositoryUserRepository")
- * @UniqueEntity("email", message="This email is already in use.")
- * @UniqueEntity("username", message="This username is already in use")
- */
- class User implements UserInterface, Serializable
- {
- private $roles = "ROLE_USER";
- /**
- * @ORMColumn(name="salt",type="string", length=255)
- */
- private $salt = "saltyboye";
- /**
- * @ORMId()
- * @ORMGeneratedValue()
- * @ORMColumn(type="integer")
- */
- private $id;
- /**
- * @ORMColumn(name="username",type="string", length=255, unique=true)
- */
- private $username;
- /**
- * @ORMColumn(name = "password", type="string", length=255)
- */
- private $password;
- /**
- * @ORMColumn(name="email", type="string", length=255, unique=true)
- */
- private $email;
- /**
- * @ORMColumn(type="datetime")
- */
- private $registeredOn;
- /**
- * @ORMColumn(type="integer", nullable=true)
- */
- private $referrer;
- /**
- * @ORMColumn(type="smallint")
- */
- private $entries;
- /**
- * @ORMColumn(type="string", length=3)
- */
- private $currency;
- /** @see Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->registeredOn,
- $this->id,
- $this->email,
- $this->username,
- $this->password,
- $this->roles,
- $this->referrer,
- $this->currency,
- $this->entries,
- $this->salt));
- }
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->email,
- $this->username,
- $this->password,
- $this->roles,
- $this->referrer,
- $this->currency,
- $this->entries,
- $this->salt) = unserialize($serialized, array('allowed_classes' => false));
- }
- public function eraseCredentials()
- {
- }
- public function getRoles()
- {
- return array("ROLE_USER");
- }
- public function getSalt()
- {
- return $this->salt;
- }
- public function getId()
- {
- return $this->id;
- }
- public function getUsername(): ?string
- {
- return $this->username;
- }
- public function setUsername(string $username): self
- {
- $this->username = $username;
- return $this;
- }
- public function getPassword(): ?string
- {
- return $this->password;
- }
- public function setPassword(string $password): self
- {
- $this->password = $password;
- return $this;
- }
- public function getEmail(): ?string
- {
- return $this->email;
- }
- public function setEmail(string $email): self
- {
- $this->email = $email;
- return $this;
- }
- public function getRegisteredOn(): ?DateTimeInterface
- {
- return $this->registeredOn;
- }
- public function setRegisteredOn(DateTimeInterface $registeredOn): self
- {
- $this->registeredOn = $registeredOn;
- return $this;
- }
- public function getReferrer(): ?int
- {
- return $this->referrer;
- }
- public function setReferrer(?int $referrer): self
- {
- $this->referrer = $referrer;
- return $this;
- }
- public function getEntries(): ?smallint
- {
- return $this->entries;
- }
- public function setEntries($entries): self
- {
- $this->entries = $entries;
- return $this;
- }
- public function setCurrency($currency): self
- {
- $this->currency = $currency;
- return $this;
- }
- public function getCurrency(): ?string
- {
- return $this->currency;
- }
- }
- security:
- hide_user_not_found: false
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- encoders:
- AppEntityUser: sha256
- providers:
- in_memory: { memory: ~ }
- main_db_provider:
- entity:
- class: AppEntityUser
- property: username
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- main:
- # anonymous: true
- pattern: ^/ #test
- anonymous: ~
- form_login:
- login_path: login
- check_path: login
- csrf_token_generator: security.csrf.token_manager
- provider: main_db_provider
- # activate different ways to authenticate
- # http_basic: true
- # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
- # form_login: true
- # https://symfony.com/doc/current/security/form_login_setup.html
- # 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: ^/$, roles: ROLE_USER }
- # - { path: ^/$, roles: ROLE_USER }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement