Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by IntelliJ IDEA.
  4. * Copyright (c) 2008-2011, Kostadin Mehomiyski
  5. * All rights reserved.
  6. *
  7. * Author: Kostadin Mehomiyski
  8. * E-mail: kostadin.mehomiyski@gmail.com
  9. * License: <license>
  10. * Description: <description>
  11. *
  12. * Created: 4/3/11 @ 11:28 PM EET
  13. */
  14.  
  15. namespace SyntheticMinds\WebBundle\Entity;
  16. use Symfony\Component\Security\Core\User\UserInterface;
  17.  
  18. /** @orm:Entity @orm:Table(name="users") */
  19. class User implements UserInterface {
  20. /** @orm:Id @orm:Column(type="integer") @orm:GeneratedValue(strategy="AUTO") */
  21. protected $id;
  22.  
  23. /** @orm:Column(type="string", length=50, unique=true, nullable=false) */
  24. protected $username;
  25.  
  26. /** @orm:Column(type="string", length=40, nullable=false) */
  27. protected $password;
  28.  
  29. /** @orm:Column(type="string", length=40, nullable=false) */
  30. protected $salt;
  31.  
  32. /** @orm:Column(type="string", length=40, nullable=false) */
  33. protected $role;
  34.  
  35. public function setPassword($password) {
  36. $this->password = $password;
  37. }
  38.  
  39. public function setSalt($salt) {
  40. $this->salt = $salt;
  41. }
  42.  
  43. /**
  44. * The equality comparison should neither be done by referential equality
  45. * nor by comparing identities (i.e. getId() === getId()).
  46. *
  47. * However, you do not need to compare every attribute, but only those that
  48. * are relevant for assessing whether re-authentication is required.
  49. *
  50. * @param UserInterface $user
  51. * @return Boolean
  52. */
  53. public function equals(UserInterface $user) {
  54. if ($this->username == $user->getUsername() && $this->salt == $user->getSalt())
  55. return true;
  56. else
  57. return false;
  58. }
  59.  
  60. /**
  61. * Removes sensitive data from the user.
  62. *
  63. * @return void
  64. */
  65. public function eraseCredentials() {
  66. // TODO: Implement eraseCredentials() method.
  67. }
  68.  
  69. /**
  70. * Returns the password used to authenticate the user.
  71. *
  72. * @return string The password
  73. */
  74. public function getPassword() {
  75. return $this->password;
  76. }
  77.  
  78. /**
  79. * Returns the roles granted to the user.
  80. *
  81. * @return Role[] The user roles
  82. */
  83. public function getRoles() {
  84. return $this->role;
  85. }
  86.  
  87. /**
  88. * Returns the salt.
  89. *
  90. * @return string The salt
  91. */
  92. public function getSalt() {
  93. return $this->salt;
  94. }
  95.  
  96. /**
  97. * Returns the username used to authenticate the user.
  98. *
  99. * @return string The username
  100. */
  101. public function getUsername() {
  102. $this->username;
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement