-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserRecoveryCode.php
More file actions
67 lines (52 loc) · 2.34 KB
/
UserRecoveryCode.php
File metadata and controls
67 lines (52 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php namespace App\libs\Auth\Models;
/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Auth\User;
use Doctrine\ORM\Mapping AS ORM;
#[ORM\Table(name: 'user_recovery_codes')]
#[ORM\Entity(repositoryClass: \App\Repositories\DoctrineUserRecoveryCodeRepository::class)]
class UserRecoveryCode
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(name: 'id', type: 'integer', unique: true, nullable: false)]
protected $id;
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: \Auth\User::class)]
private $user;
#[ORM\Column(name: 'code_hash', type: 'string', length: 255)]
private $code_hash;
#[ORM\Column(name: 'used_at', type: 'datetime', nullable: true)]
private $used_at;
#[ORM\Column(name: 'created_at', type: 'datetime')]
private $created_at;
public function __construct()
{
$this->created_at = new \DateTime('now', new \DateTimeZone('UTC'));
$this->used_at = null;
}
public function getId(): int { return (int) $this->id; }
public function getUser(): User { return $this->user; }
public function setUser(User $user): void { $this->user = $user; }
public function getCodeHash(): string { return $this->code_hash; }
public function setCodeHash(string $value): void { $this->code_hash = $value; }
public function getUsedAt(): ?\DateTime { return $this->used_at; }
public function setUsedAt(?\DateTime $value): void { $this->used_at = $value; }
public function getCreatedAt(): \DateTime { return $this->created_at; }
public function isUsed(): bool { return !is_null($this->used_at); }
public function markUsed(): void
{
$this->used_at = new \DateTime('now', new \DateTimeZone('UTC'));
}
public function __get($name) { return $this->{$name}; }
}