1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* Created by PhpStorm. |
5
|
|
|
* User: benedikt |
6
|
|
|
* Date: 9/15/17 |
7
|
|
|
* Time: 10:48 PM |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Tfboe\FmLib\Entity\Traits; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
14
|
|
|
use LaravelDoctrine\ORM\Auth\Authenticatable; |
15
|
|
|
use Tfboe\FmLib\Entity\Helpers\TimestampableEntity; |
16
|
|
|
use Tfboe\FmLib\Entity\Helpers\UUIDEntity; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Trait User |
21
|
|
|
* @package Tfboe\FmLib\Entity\Traits |
22
|
|
|
*/ |
23
|
|
|
trait User |
24
|
|
|
{ |
25
|
|
|
use Authenticatable; |
26
|
|
|
use TimestampableEntity; |
27
|
|
|
use UUIDEntity; |
28
|
|
|
|
29
|
|
|
//<editor-fold desc="Fields"> |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\Column(type="string") |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $email; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @ORM\Column(type="integer") |
39
|
|
|
* @var int |
40
|
|
|
*/ |
41
|
|
|
private $jwtVersion; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @ORM\Column(type="integer") |
45
|
|
|
* @var int |
46
|
|
|
*/ |
47
|
|
|
private $confirmedAGBVersion; |
48
|
|
|
//</editor-fold desc="Fields"> |
49
|
|
|
|
50
|
|
|
//<editor-fold desc="Constructor"> |
51
|
|
|
//</editor-fold desc="Constructor"> |
52
|
|
|
|
53
|
|
|
//<editor-fold desc="Public Methods"> |
54
|
|
|
/** |
55
|
|
|
* @return int |
56
|
|
|
*/ |
57
|
|
|
public function getConfirmedAGBVersion(): int |
58
|
|
|
{ |
59
|
|
|
return $this->confirmedAGBVersion; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getEmail(): string |
66
|
|
|
{ |
67
|
|
|
return $this->email; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Return a key value array, containing any custom claims to be added to the JWT. |
72
|
|
|
* |
73
|
|
|
* @return array |
74
|
|
|
*/ |
75
|
|
|
public function getJWTCustomClaims(): array |
76
|
|
|
{ |
77
|
|
|
return [ |
78
|
|
|
'ver' => $this->jwtVersion |
79
|
|
|
]; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get the identifier that will be stored in the subject claim of the JWT. |
84
|
|
|
* |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getJWTIdentifier(): string |
88
|
|
|
{ |
89
|
|
|
return $this->getId(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return int |
94
|
|
|
*/ |
95
|
|
|
public function getJwtVersion(): int |
96
|
|
|
{ |
97
|
|
|
return $this->jwtVersion; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param mixed $confirmedAGBVersion |
102
|
|
|
*/ |
103
|
|
|
public function setConfirmedAGBVersion($confirmedAGBVersion) |
104
|
|
|
{ |
105
|
|
|
$this->confirmedAGBVersion = $confirmedAGBVersion; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param mixed $email |
110
|
|
|
*/ |
111
|
|
|
public function setEmail($email) |
112
|
|
|
{ |
113
|
|
|
$this->email = $email; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param mixed $jwtVersion |
118
|
|
|
*/ |
119
|
|
|
public function setJwtVersion($jwtVersion) |
120
|
|
|
{ |
121
|
|
|
$this->jwtVersion = $jwtVersion; |
122
|
|
|
} |
123
|
|
|
//</editor-fold desc="Public Methods"> |
124
|
|
|
|
125
|
|
|
//<editor-fold desc="Protected Final Methods"> |
126
|
|
|
/** |
127
|
|
|
* User init |
128
|
|
|
*/ |
129
|
|
|
protected final function init() |
130
|
|
|
{ |
131
|
|
|
$this->jwtVersion = 1; |
132
|
|
|
$this->confirmedAGBVersion = 0; |
133
|
|
|
} |
134
|
|
|
//</editor-fold desc="Protected Final Methods"> |
135
|
|
|
} |