Advertisement
Guest User

Untitled

a guest
Jul 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6. use SymfonyBridgeDoctrineValidatorConstraintsUniqueEntity;
  7. use SymfonyComponentSecurityCoreUserUserInterface;
  8.  
  9. /**
  10. * @ORMEntity(repositoryClass="AppRepositoryUserRepository")
  11. * @UniqueEntity("email", message="This email is already in use.")
  12. * @UniqueEntity("username", message="This username is already in use")
  13. */
  14. class User implements UserInterface, Serializable
  15. {
  16.  
  17. private $roles = "ROLE_USER";
  18.  
  19. /**
  20. * @ORMColumn(name="salt",type="string", length=255)
  21. */
  22. private $salt = "saltyboye";
  23.  
  24.  
  25. /**
  26. * @ORMId()
  27. * @ORMGeneratedValue()
  28. * @ORMColumn(type="integer")
  29. */
  30. private $id;
  31.  
  32. /**
  33. * @ORMColumn(name="username",type="string", length=255, unique=true)
  34. */
  35. private $username;
  36.  
  37. /**
  38. * @ORMColumn(name = "password", type="string", length=255)
  39. */
  40. private $password;
  41.  
  42. /**
  43. * @ORMColumn(name="email", type="string", length=255, unique=true)
  44. */
  45. private $email;
  46.  
  47. /**
  48. * @ORMColumn(type="datetime")
  49. */
  50. private $registeredOn;
  51.  
  52. /**
  53. * @ORMColumn(type="integer", nullable=true)
  54. */
  55. private $referrer;
  56.  
  57. /**
  58. * @ORMColumn(type="smallint")
  59. */
  60. private $entries;
  61.  
  62. /**
  63. * @ORMColumn(type="string", length=3)
  64. */
  65. private $currency;
  66.  
  67.  
  68. /** @see Serializable::serialize() */
  69. public function serialize()
  70. {
  71. return serialize(array(
  72. $this->registeredOn,
  73. $this->id,
  74. $this->email,
  75. $this->username,
  76. $this->password,
  77. $this->roles,
  78. $this->referrer,
  79. $this->currency,
  80. $this->entries,
  81. $this->salt));
  82. }
  83.  
  84. public function unserialize($serialized)
  85. {
  86. list (
  87. $this->id,
  88. $this->email,
  89. $this->username,
  90. $this->password,
  91. $this->roles,
  92. $this->referrer,
  93. $this->currency,
  94. $this->entries,
  95. $this->salt) = unserialize($serialized, array('allowed_classes' => false));
  96. }
  97. public function eraseCredentials()
  98. {
  99.  
  100. }
  101. public function getRoles()
  102. {
  103. return array("ROLE_USER");
  104. }
  105.  
  106.  
  107. public function getSalt()
  108. {
  109. return $this->salt;
  110. }
  111.  
  112.  
  113. public function getId()
  114. {
  115. return $this->id;
  116. }
  117.  
  118. public function getUsername(): ?string
  119. {
  120. return $this->username;
  121. }
  122.  
  123. public function setUsername(string $username): self
  124. {
  125. $this->username = $username;
  126.  
  127. return $this;
  128. }
  129.  
  130. public function getPassword(): ?string
  131. {
  132. return $this->password;
  133. }
  134.  
  135. public function setPassword(string $password): self
  136. {
  137. $this->password = $password;
  138.  
  139. return $this;
  140. }
  141.  
  142. public function getEmail(): ?string
  143. {
  144. return $this->email;
  145. }
  146.  
  147. public function setEmail(string $email): self
  148. {
  149. $this->email = $email;
  150.  
  151. return $this;
  152. }
  153.  
  154. public function getRegisteredOn(): ?DateTimeInterface
  155. {
  156. return $this->registeredOn;
  157. }
  158.  
  159. public function setRegisteredOn(DateTimeInterface $registeredOn): self
  160. {
  161. $this->registeredOn = $registeredOn;
  162.  
  163. return $this;
  164. }
  165.  
  166. public function getReferrer(): ?int
  167. {
  168. return $this->referrer;
  169. }
  170.  
  171. public function setReferrer(?int $referrer): self
  172. {
  173. $this->referrer = $referrer;
  174.  
  175. return $this;
  176. }
  177.  
  178. public function getEntries(): ?smallint
  179. {
  180. return $this->entries;
  181. }
  182.  
  183. public function setEntries($entries): self
  184. {
  185. $this->entries = $entries;
  186.  
  187. return $this;
  188. }
  189.  
  190. public function setCurrency($currency): self
  191. {
  192. $this->currency = $currency;
  193.  
  194. return $this;
  195. }
  196. public function getCurrency(): ?string
  197. {
  198. return $this->currency;
  199. }
  200.  
  201. }
  202.  
  203. security:
  204. hide_user_not_found: false
  205. # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
  206. encoders:
  207. AppEntityUser: sha256
  208. providers:
  209. in_memory: { memory: ~ }
  210. main_db_provider:
  211. entity:
  212. class: AppEntityUser
  213. property: username
  214.  
  215. firewalls:
  216. dev:
  217. pattern: ^/(_(profiler|wdt)|css|images|js)/
  218. security: false
  219. main:
  220. # anonymous: true
  221. pattern: ^/ #test
  222. anonymous: ~
  223. form_login:
  224. login_path: login
  225. check_path: login
  226. csrf_token_generator: security.csrf.token_manager
  227. provider: main_db_provider
  228.  
  229. # activate different ways to authenticate
  230.  
  231. # http_basic: true
  232. # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
  233.  
  234. # form_login: true
  235. # https://symfony.com/doc/current/security/form_login_setup.html
  236.  
  237. # Easy way to control access for large sections of your site
  238. # Note: Only the *first* access control that matches will be used
  239. access_control:
  240. - { path: ^/$, roles: ROLE_USER }
  241. # - { path: ^/$, roles: ROLE_USER }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement