Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # app/config/security.yml
- security:
- encoders:
- DeliveryAdminBundleEntityUser:
- algorithm: bcrypt
- providers:
- our_db_provider:
- entity:
- class: DeliveryAdminBundle:User
- property: username
- access_control:
- - { path: ^/admin, roles: ROLE_USER }
- firewalls:
- main:
- pattern: ^/admin
- http_basic: ~
- provider: our_db_provider
- <?php
- namespace DeliveryAdminBundleEntity;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentSecurityCoreUserUserInterface;
- /**
- * @ORMTable(name="app_users")
- * @ORMEntity(repositoryClass="DeliveryAdminBundleRepositoryUserRepository")
- */
- class User implements UserInterface, Serializable
- {
- /**
- * @ORMColumn(type="integer")
- * @ORMId
- * @ORMGeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORMColumn(type="string", length=25, unique=true)
- */
- private $username;
- /**
- * @ORMColumn(type="string", length=64)
- */
- private $password;
- /**
- * @ORMColumn(type="string", length=60, unique=true)
- */
- private $email;
- /**
- * @ORMColumn(name="is_active", type="boolean")
- */
- private $isActive;
- public function __construct()
- {
- $this->isActive = true;
- // may not be needed, see section on salt below
- // $this->salt = md5(uniqid(null, true));
- }
- public function getUsername()
- {
- return $this->username;
- }
- public function getSalt()
- {
- // you *may* need a real salt depending on your encoder
- // see section on salt below
- return null;
- }
- public function getPassword()
- {
- return $this->password;
- }
- public function getRoles()
- {
- return array('ROLE_USER');
- }
- public function eraseCredentials()
- {
- }
- /** @see Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt,
- ));
- }
- /** @see Serializable::unserialize() */
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt
- ) = unserialize($serialized);
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- *
- * @return User
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * Set password
- *
- * @param string $password
- *
- * @return User
- */
- public function setPassword($password)
- {
- if ($password) {
- $this->password = password_hash($password, PASSWORD_DEFAULT);
- }
- return $this;
- }
- /**
- * Set email
- *
- * @param string $email
- *
- * @return User
- */
- public function setEmail($email)
- {
- $this->email = $email;
- return $this;
- }
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set isActive
- *
- * @param boolean $isActive
- *
- * @return User
- */
- public function setIsActive($isActive)
- {
- $this->isActive = $isActive;
- return $this;
- }
- /**
- * Get isActive
- *
- * @return boolean
- */
- public function getIsActive()
- {
- return $this->isActive;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement