AccessTmp.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <?php
  2. namespace AppBundle\Entity\AccessWish;
  3. use AppBundle\Entity\Organization\Organization;
  4. use AppBundle\Entity\Traits\TimestampableEntity;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8. * Contient les access temporaires d'une organisation = les email qui ont fait la procédure signin
  9. */
  10. #[ORM\Entity]
  11. class AccessTmp
  12. {
  13. use TimestampableEntity;
  14. /**
  15. * @var int
  16. */
  17. #[ORM\Column(type: 'integer')]
  18. #[ORM\Id]
  19. #[ORM\GeneratedValue(strategy: 'AUTO')]
  20. private $id;
  21. /**
  22. * @var Organization
  23. */
  24. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization')]
  25. private $organization;
  26. /**
  27. * @var string
  28. */
  29. #[Assert\Type(type: 'string')]
  30. #[ORM\Column(type: 'string', nullable: true)]
  31. private $mail;
  32. /**
  33. * @var string
  34. */
  35. #[Assert\Type(type: 'string')]
  36. #[ORM\Column(type: 'string', nullable: true)]
  37. private $username;
  38. /**
  39. * @var string
  40. */
  41. #[Assert\Type(type: 'string')]
  42. #[ORM\Column(type: 'string', nullable: true)]
  43. private $password;
  44. /**
  45. * @var string
  46. */
  47. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  48. #[Assert\Type(type: 'string')]
  49. #[Assert\Length(max: 100, maxMessage: 'invalid-max-length')]
  50. private $name;
  51. /**
  52. * @var string
  53. */
  54. #[ORM\Column(type: 'string', length: 50, nullable: true)]
  55. #[Assert\Type(type: 'string')]
  56. #[Assert\Length(max: 50, maxMessage: 'invalid-max-length')]
  57. private $givenName;
  58. /**
  59. * @var \DateTime Date of birth.
  60. */
  61. #[ORM\Column(type: 'date', nullable: true)]
  62. #[Assert\Date(message: 'invalid-date')]
  63. private $birthDate;
  64. /**
  65. * @var bool
  66. */
  67. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  68. #[Assert\Type(type: 'boolean')]
  69. #[Assert\NotNull]
  70. private $informationRetainedAndUsed = false;
  71. /**
  72. * @var bool
  73. */
  74. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  75. #[Assert\Type(type: 'boolean')]
  76. #[Assert\NotNull]
  77. private $cgu = false;
  78. /**
  79. * Random string sent to the user email address in order to verify it
  80. *
  81. * @var string
  82. */
  83. #[ORM\Column(name: 'confirmation_token', type: 'string', nullable: false)]
  84. private $confirmationToken;
  85. /**
  86. * @var \DateTime
  87. */
  88. #[ORM\Column(type: 'datetime', nullable: false)]
  89. private $tokenGivenDate;
  90. public function __construct()
  91. {
  92. }
  93. /**
  94. * Sets id.
  95. *
  96. * @param int $id
  97. *
  98. * @return $this
  99. */
  100. public function setId($id)
  101. {
  102. $this->id = $id;
  103. return $this;
  104. }
  105. /**
  106. * Gets id.
  107. *
  108. * @return int
  109. */
  110. public function getId()
  111. {
  112. return $this->id;
  113. }
  114. /**
  115. * Sets organization.
  116. *
  117. * @param Organization $organization
  118. *
  119. * @return $this
  120. */
  121. public function setOrganization(Organization $organization = null)
  122. {
  123. $this->organization = $organization;
  124. return $this;
  125. }
  126. /**
  127. * Gets organization.
  128. *
  129. * @return Organization
  130. */
  131. public function getOrganization()
  132. {
  133. return $this->organization;
  134. }
  135. /**
  136. * Sets mail.
  137. *
  138. * @param string $mail
  139. *
  140. * @return $this
  141. */
  142. public function setMail($mail)
  143. {
  144. $this->mail = $mail;
  145. return $this;
  146. }
  147. /**
  148. * Gets mail.
  149. *
  150. * @return string
  151. */
  152. public function getMail()
  153. {
  154. return $this->mail;
  155. }
  156. /**
  157. * Sets username.
  158. *
  159. * @param string $username
  160. *
  161. * @return $this
  162. */
  163. public function setUsername($username)
  164. {
  165. $this->username = $username;
  166. return $this;
  167. }
  168. /**
  169. * Gets username.
  170. *
  171. * @return string
  172. */
  173. public function getUsername()
  174. {
  175. return $this->username;
  176. }
  177. /**
  178. * Sets password.
  179. *
  180. * @param string $password
  181. *
  182. * @return $this
  183. */
  184. public function setPassword($password)
  185. {
  186. $this->password = $password;
  187. return $this;
  188. }
  189. /**
  190. * Gets password.
  191. *
  192. * @return string
  193. */
  194. public function getPassword()
  195. {
  196. return $this->password;
  197. }
  198. /**
  199. * Sets confirmation token.
  200. *
  201. * @param string $token
  202. *
  203. * @return $this
  204. */
  205. public function setConfirmationToken($token)
  206. {
  207. $this->confirmationToken = $token;
  208. return $this;
  209. }
  210. /**
  211. * Gets confirmation token.
  212. *
  213. * @return string
  214. */
  215. public function getConfirmationToken()
  216. {
  217. return $this->confirmationToken;
  218. }
  219. /**
  220. * set token given date
  221. * @param \DateTime $tokenGivenDate
  222. * @return $this
  223. */
  224. public function setTokenGivenDate(\DateTime $tokenGivenDate)
  225. {
  226. $this->tokenGivenDate = $tokenGivenDate;
  227. return $this;
  228. }
  229. /**
  230. * Gets token given date
  231. *
  232. * @return \DateTime
  233. */
  234. public function getTokenGivenDate()
  235. {
  236. return $this->tokenGivenDate;
  237. }
  238. public function isTokenNonExpired($ttl)
  239. {
  240. return $this->getTokenGivenDate() instanceof \DateTime &&
  241. $this->getTokenGivenDate()->getTimestamp() + $ttl > time();
  242. }
  243. /**
  244. * Set name
  245. *
  246. * @param string $name
  247. *
  248. * @return AccessTmp
  249. */
  250. public function setName($name)
  251. {
  252. $this->name = $name;
  253. return $this;
  254. }
  255. /**
  256. * Get name
  257. *
  258. * @return string
  259. */
  260. public function getName()
  261. {
  262. return $this->name;
  263. }
  264. /**
  265. * Set givenName
  266. *
  267. * @param string $givenName
  268. *
  269. * @return AccessTmp
  270. */
  271. public function setGivenName($givenName)
  272. {
  273. $this->givenName = $givenName;
  274. return $this;
  275. }
  276. /**
  277. * Get givenName
  278. *
  279. * @return string
  280. */
  281. public function getGivenName()
  282. {
  283. return $this->givenName;
  284. }
  285. /**
  286. * Set birthDate
  287. *
  288. * @param \DateTime $birthDate
  289. *
  290. * @return AccessTmp
  291. */
  292. public function setBirthDate($birthDate)
  293. {
  294. $this->birthDate = $birthDate;
  295. return $this;
  296. }
  297. /**
  298. * Get birthDate
  299. *
  300. * @return \DateTime
  301. */
  302. public function getBirthDate()
  303. {
  304. return $this->birthDate;
  305. }
  306. /**
  307. * Set informationRetainedAndUsed
  308. *
  309. * @param boolean $informationRetainedAndUsed
  310. *
  311. * @return AccessTmp
  312. */
  313. public function setInformationRetainedAndUsed($informationRetainedAndUsed)
  314. {
  315. $this->informationRetainedAndUsed = $informationRetainedAndUsed;
  316. return $this;
  317. }
  318. /**
  319. * Get informationRetainedAndUsed
  320. *
  321. * @return boolean
  322. */
  323. public function getInformationRetainedAndUsed()
  324. {
  325. return $this->informationRetainedAndUsed;
  326. }
  327. /**
  328. * Set cgu
  329. *
  330. * @param boolean $cgu
  331. *
  332. * @return AccessTmp
  333. */
  334. public function setCgu($cgu)
  335. {
  336. $this->cgu = $cgu;
  337. return $this;
  338. }
  339. /**
  340. * Get cgu
  341. *
  342. * @return boolean
  343. */
  344. public function getCgu()
  345. {
  346. return $this->cgu;
  347. }
  348. }