Skip to content

Commit c3f9c9d

Browse files
chore: Add UniqueConstraint annotation to mirror the database migration
1 parent 13bdf4a commit c3f9c9d

1 file changed

Lines changed: 77 additions & 21 deletions

File tree

app/libs/Auth/Models/UserTrustedDevice.php

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php namespace App\libs\Auth\Models;
1+
<?php
2+
namespace App\libs\Auth\Models;
23
/**
34
* Copyright 2026 OpenStack Foundation
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,10 +15,11 @@
1415

1516
use App\Models\Utils\BaseEntity;
1617
use Auth\User;
17-
use Doctrine\ORM\Mapping AS ORM;
18+
use Doctrine\ORM\Mapping as ORM;
1819

1920
#[ORM\Table(name: 'user_trusted_devices')]
2021
#[ORM\Entity(repositoryClass: \App\Repositories\DoctrineUserTrustedDeviceRepository::class)]
22+
#[ORM\UniqueConstraint(name: 'utd_user_device_uniq', columns: ['user_id', 'device_identifier'])]
2123
#[ORM\HasLifecycleCallbacks]
2224
class UserTrustedDevice extends BaseEntity
2325
{
@@ -55,30 +57,84 @@ public function __construct()
5557
$this->is_revoked = false;
5658
}
5759

58-
public function getUser(): User { return $this->user; }
59-
public function setUser(User $user): void { $this->user = $user; }
60+
public function getUser(): User
61+
{
62+
return $this->user;
63+
}
64+
public function setUser(User $user): void
65+
{
66+
$this->user = $user;
67+
}
6068

61-
public function getDeviceIdentifier(): string { return $this->device_identifier; }
62-
public function setDeviceIdentifier(string $value): void { $this->device_identifier = $value; }
69+
public function getDeviceIdentifier(): string
70+
{
71+
return $this->device_identifier;
72+
}
73+
public function setDeviceIdentifier(string $value): void
74+
{
75+
$this->device_identifier = $value;
76+
}
6377

64-
public function getDeviceName(): string { return $this->device_name; }
65-
public function setDeviceName(string $value): void { $this->device_name = $value; }
78+
public function getDeviceName(): string
79+
{
80+
return $this->device_name;
81+
}
82+
public function setDeviceName(string $value): void
83+
{
84+
$this->device_name = $value;
85+
}
6686

67-
public function getIpAddress(): string { return $this->ip_address; }
68-
public function setIpAddress(string $value): void { $this->ip_address = $value; }
87+
public function getIpAddress(): string
88+
{
89+
return $this->ip_address;
90+
}
91+
public function setIpAddress(string $value): void
92+
{
93+
$this->ip_address = $value;
94+
}
6995

70-
public function getUserAgent(): string { return $this->user_agent; }
71-
public function setUserAgent(string $value): void { $this->user_agent = $value; }
96+
public function getUserAgent(): string
97+
{
98+
return $this->user_agent;
99+
}
100+
public function setUserAgent(string $value): void
101+
{
102+
$this->user_agent = $value;
103+
}
72104

73-
public function getTrustedAt(): \DateTime { return $this->trusted_at; }
74-
public function setTrustedAt(\DateTime $value): void { $this->trusted_at = $value; }
105+
public function getTrustedAt(): \DateTime
106+
{
107+
return $this->trusted_at;
108+
}
109+
public function setTrustedAt(\DateTime $value): void
110+
{
111+
$this->trusted_at = $value;
112+
}
75113

76-
public function getExpiresAt(): \DateTime { return $this->expires_at; }
77-
public function setExpiresAt(\DateTime $value): void { $this->expires_at = $value; }
114+
public function getExpiresAt(): \DateTime
115+
{
116+
return $this->expires_at;
117+
}
118+
public function setExpiresAt(\DateTime $value): void
119+
{
120+
$this->expires_at = $value;
121+
}
78122

79-
public function getLastSeenAt(): \DateTime { return $this->last_seen_at; }
80-
public function setLastSeenAt(\DateTime $value): void { $this->last_seen_at = $value; }
123+
public function getLastSeenAt(): \DateTime
124+
{
125+
return $this->last_seen_at;
126+
}
127+
public function setLastSeenAt(\DateTime $value): void
128+
{
129+
$this->last_seen_at = $value;
130+
}
81131

82-
public function isRevoked(): bool { return (bool) $this->is_revoked; }
83-
public function setIsRevoked(bool $value): void { $this->is_revoked = $value; }
84-
}
132+
public function isRevoked(): bool
133+
{
134+
return (bool) $this->is_revoked;
135+
}
136+
public function setIsRevoked(bool $value): void
137+
{
138+
$this->is_revoked = $value;
139+
}
140+
}

0 commit comments

Comments
 (0)