Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- security:
- encoders:
- AppAppBundleEntityUser:
- algorithm: sha512
- encode-as-base64: true
- iterations: 10
- providers:
- main:
- entity: { class: AppBundle:User, property: username }
- firewalls:
- main:
- pattern: /.*
- form_login:
- check_path: /login_check/
- login_path: /login/
- logout: true
- security: true
- anonymous: true
- access_control:
- - { path: /admin/.*, role: ROLE_ADMIN }
- - { path: /.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
- <?php
- namespace AppAppBundleEntity;
- use DoctrineCommonCollectionsArrayCollection;;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentSecurityCoreUserUserInterface;
- /**
- * @ORMEntity
- * @ORMTable(name="user")
- * @ORMHasLifecycleCallbacks
- */
- class User implements UserInterface
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMColumn(type="string", length=255, unique=true)
- */
- protected $username;
- /**
- * @ORMColumn(type="string", length=255)
- */
- protected $password;
- /**
- * @ORMColumn(type="string", length=255)
- */
- protected $salt;
- /**
- * @ORMManyToMany(targetEntity="Role")
- * @ORMJoinTable(name="user_role",
- * joinColumns={@ORMJoinColumn(name="user_id", referencedColumnName="id")},
- * inverseJoinColumns={@ORMJoinColumn(name="role_id", referencedColumnName="id")}
- * )
- */
- protected $userRoles;
- /**
- * @ORMColumn(type="boolean")
- */
- protected $status;
- /**
- * @ORMColumn(type="string")
- */
- protected $email;
- /**
- * @return mixed
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * @param mixed $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * @ORMColumn(name="is_active", type="boolean")
- */
- protected $isActive;
- /**
- * @ORMColumn(type="datetime")
- */
- protected $date_added;
- public function __construct()
- {
- $this->userRoles = new ArrayCollection();
- $this->setDateAdded(new DateTime());
- }
- /**
- * Clear user privileges
- **/
- public function eraseCredentials()
- {
- }
- /**
- * @return array of Role object
- */
- public function getRoles()
- {
- return $this->getUserRoles();
- }
- /**
- * Compare one user to another user
- * and determine if its same user
- *
- * @param UserInterface $user
- * @return boolean True if equals and false otherwise
- */
- public function equals(UserInterface $user)
- {
- return md5($this->getUsername()) == md5($user->getUsername());
- }
- /**
- * 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;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @return string
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $password;
- }
- /**
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @return string
- */
- public function setSalt($salt)
- {
- $this->salt = $salt;
- return $this;
- }
- /**
- * @return string
- */
- public function getSalt()
- {
- return $this->salt;
- }
- /**
- * Set status
- *
- * @param boolean $status
- *
- * @return User
- */
- public function setStatus($status)
- {
- $this->status = $status;
- return $this;
- }
- /**
- * Get status
- *
- * @return boolean
- */
- public function getStatus()
- {
- return $this->status;
- }
- /**
- * Set dateAdded
- *
- * @param DateTime $dateAdded
- *
- * @return User
- */
- public function setDateAdded($dateAdded)
- {
- $this->date_added = $dateAdded;
- return $this;
- }
- /**
- * Get dateAdded
- *
- * @return DateTime
- */
- public function getDateAdded()
- {
- return $this->date_added;
- }
- /**
- * Get user roles
- *
- * @return ArrayCollection
- */
- public function getUserRoles()
- {
- return $this->userRoles;
- }
- /**
- * 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;
- }
- /**
- * Add userRole
- *
- * @param AppAppBundleEntityRole $userRole
- *
- * @return User
- */
- public function addUserRole(Role $userRole)
- {
- $this->userRoles[] = $userRole;
- return $this;
- }
- /**
- * Remove userRole
- *
- * @param AppAppBundleEntityRole $userRole
- */
- public function removeUserRole(Role $userRole)
- {
- $this->userRoles->removeElement($userRole);
- }
- }
- <?php
- namespace AppAppBundleEntity;
- use SymfonyComponentSecurityCoreRoleRoleInterface;
- use DoctrineORMMapping as ORM;
- /**
- * @ORMEntity
- * @ORMTable(name="role")
- */
- class Role implements RoleInterface
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- *
- * @var integer $id
- */
- protected $id;
- /**
- * @ORMColumn(type="string")
- *
- * @var string $name
- */
- protected $name;
- /**
- * @ORMColumn(type="datetime", name="created_at")
- *
- * @var DateTime $createdAt
- */
- protected $createdAt;
- /**
- * Геттер для id.
- *
- * @return integer The id.
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Геттер для названия роли.
- *
- * @return string The name.
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Сеттер для названия роли.
- *
- * @param string $value The name.
- */
- public function setName($value)
- {
- $this->name = $value;
- }
- /**
- * Геттер для даты создания роли.
- *
- * @return DateTime A DateTime object.
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
- /**
- * Конструктор класса
- */
- public function __construct()
- {
- $this->createdAt = new DateTime();
- }
- /**
- * Реализация метода, требуемого интерфейсом RoleInterface.
- *
- * @return string The role.
- */
- public function getRole()
- {
- return $this->getName();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement