src/Entity/UserGlobalPasswordAccess.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserGlobalPasswordAccessRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7.  * "GLOBAL SIFRE" yetkisi — bu kullanicinin KENDI sifresi, secili serviste
  8.  * BASKA kullanicilarin hesabina giris yapmak icin de gecerlidir.
  9.  *
  10.  * Ornek: Fatih'e `self` (ERP) satiri verilirse, Fatih ERP giris ekranina
  11.  * Daniel'in e-postasini + KENDI sifresini yazarak Daniel olarak girer. Amac
  12.  * diger kullanicilarin ekranini/tepkisini gorebilmektir.
  13.  *
  14.  * BU TABLO `user_service_access` DEGILDIR — orasi "bu kullanici bu servise
  15.  * KENDI adina girebilir mi" sorusunu cevaplar. Burasi bambaska bir eksendir:
  16.  * "bu kullanicinin sifresi bu serviste HERKESIN kapisini acar mi". Ikisi ayni
  17.  * satirda tutulmaz; tutulsaydi impersonation yetkisi vermek icin acilan satir,
  18.  * `granted=0` degeriyle kullanicinin KENDI erisimini sessizce kapatirdi.
  19.  *
  20.  * SEMANTIK BASIT: satir VARSA yetki vardir, YOKSA yoktur. `user_service_access`
  21.  * gibi "kayit yok -> servisin is_default'u" kurali burada GECERLI DEGILDIR —
  22.  * hicbir servis bu yetkiyi varsayilan olarak vermez.
  23.  *
  24.  * (user, service) cifti benzersizdir.
  25.  *
  26.  * @ORM\Entity(repositoryClass=UserGlobalPasswordAccessRepository::class)
  27.  * @ORM\Table(
  28.  *     name="user_global_password_access",
  29.  *     uniqueConstraints={
  30.  *         @ORM\UniqueConstraint(name="uniq_user_global_password_service", columns={"user_id", "service_id"})
  31.  *     }
  32.  * )
  33.  * @ORM\HasLifecycleCallbacks
  34.  */
  35. class UserGlobalPasswordAccess
  36. {
  37.     /**
  38.      * @ORM\Id
  39.      * @ORM\GeneratedValue
  40.      * @ORM\Column(type="integer")
  41.      * @Groups({
  42.      *     "user_global_password_access@ref",
  43.      *     "user_global_password_access@base",
  44.      *     "user_global_password_access@core"
  45.      * })
  46.      */
  47.     private $id;
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="global_password_accesses")
  50.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  51.      * @Groups({
  52.      *     "user_global_password_access@user"
  53.      * })
  54.      */
  55.     private $user;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity=Services::class)
  58.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  59.      * @Groups({
  60.      *     "user_global_password_access@base",
  61.      *     "user_global_password_access@core"
  62.      * })
  63.      */
  64.     private $service;
  65.     /**
  66.      * @ORM\Column(type="datetime_immutable", nullable=true)
  67.      * @Groups({
  68.      *     "user_global_password_access@core"
  69.      * })
  70.      */
  71.     private $created_at;
  72.     /**
  73.      * @ORM\PrePersist
  74.      */
  75.     public function onPrePersist(): void
  76.     {
  77.         if ($this->created_at === null) {
  78.             $this->created_at = new \DateTimeImmutable();
  79.         }
  80.     }
  81.     public function getId(): ?int
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function getUser(): ?User
  86.     {
  87.         return $this->user;
  88.     }
  89.     public function setUser(?User $user): self
  90.     {
  91.         $this->user = $user;
  92.         return $this;
  93.     }
  94.     public function getService(): ?Services
  95.     {
  96.         return $this->service;
  97.     }
  98.     public function setService(?Services $service): self
  99.     {
  100.         $this->service = $service;
  101.         return $this;
  102.     }
  103.     public function getCreatedAt(): ?\DateTimeImmutable
  104.     {
  105.         return $this->created_at;
  106.     }
  107.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  108.     {
  109.         $this->created_at = $created_at;
  110.         return $this;
  111.     }
  112. }