Guest User

Untitled

a guest
Apr 19th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace App\Model\Entity;
  5. use Cake\Auth\DefaultPasswordHasher;
  6. use Cake\ORM\Entity;
  7.  
  8. /**
  9. * User Entity
  10. *
  11. * @property int $id
  12. * @property string $email
  13. * @property string $password
  14. * @property \Cake\I18n\FrozenTime|null $created
  15. * @property \Cake\I18n\FrozenTime|null $modified
  16. */
  17. class User extends Entity
  18. {
  19. /**
  20. * Fields that can be mass assigned using newEntity() or patchEntity().
  21. *
  22. * Note that when '*' is set to true, this allows all unspecified fields to
  23. * be mass assigned. For security purposes, it is advised to set '*' to false
  24. * (or remove it), and explicitly make individual fields accessible as needed.
  25. *
  26. * @var array
  27. */
  28. protected $_accessible = [
  29. 'email' => true,
  30. 'password' => true,
  31. 'created' => true,
  32. 'modified' => true,
  33. ];
  34.  
  35. /**
  36. * Fields that are excluded from JSON versions of the entity.
  37. *
  38. * @var array
  39. */
  40. protected $_hidden = [
  41. 'password',
  42. ];
  43.  
  44. protected function _setPassword(string $password) : ?string
  45. {
  46. if (strlen($password) > 0) {
  47. return (new DefaultPasswordHasher())->hash($password);
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment