17
17
use Cake \ORM \TableRegistry ;
18
18
use Cake \Routing \Router ;
19
19
use Cake \Utility \Hash ;
20
-
21
20
use DateInterval ;
22
21
use DateTimeImmutable ;
23
22
use Lcobucci \JWT \Configuration ;
24
- use Lcobucci \JWT \Signer \Key \InMemory ;
25
23
use Lcobucci \JWT \Signer \Hmac \Sha256 ;
26
- use Lcobucci \JWT \Builder ;
27
24
use Lcobucci \JWT \Signer \Hmac \Sha512 ;
25
+ use Lcobucci \JWT \Signer \Key \InMemory ;
28
26
29
27
trait JwtTokenTrait
30
28
{
@@ -50,7 +48,7 @@ public function generateTokenResponse($user)
50
48
* Generates access token.
51
49
*
52
50
* @param \Cake\Datasource\EntityInterface|array $user User info.
53
- * @param DateTimeImmutable $timestamp Timestamp.
51
+ * @param \ DateTimeImmutable $timestamp Timestamp.
54
52
* @return bool|string
55
53
*/
56
54
public function generateAccessToken ($ user , $ timestamp )
@@ -82,7 +80,7 @@ public function generateAccessToken($user, $timestamp)
82
80
* Generates refresh token.
83
81
*
84
82
* @param \Cake\Datasource\EntityInterface|array $user User info.
85
- * @param DateTimeImmutable $timestamp Timestamp.
83
+ * @param \ DateTimeImmutable $timestamp Timestamp.
86
84
* @return bool|string
87
85
*/
88
86
public function generateRefreshToken ($ user , $ timestamp )
@@ -138,26 +136,26 @@ public function generateRefreshToken($user, $timestamp)
138
136
/**
139
137
* Generates access token with life time.
140
138
*
141
- * @param DateTimeImmutable $timestamp Timestamp.
142
- * @return DateTimeImmutable
139
+ * @param \ DateTimeImmutable $timestamp Timestamp.
140
+ * @return \ DateTimeImmutable
143
141
*/
144
142
private function accessTokenLifeTime (DateTimeImmutable $ timestamp ): DateTimeImmutable
145
143
{
146
144
$ accessTokenLifeTime = Configure::read ('Api.Jwt.AccessToken.lifetime ' );
147
145
148
- return $ timestamp ->add (new DateInterval (" PT " . $ accessTokenLifeTime . " S " ));
146
+ return $ timestamp ->add (new DateInterval (' PT ' . $ accessTokenLifeTime . ' S ' ));
149
147
}
150
148
151
149
/**
152
150
* Generates refresh token with life time.
153
151
*
154
- * @param DateTimeImmutable $timestamp Timestamp.
155
- * @return DateTimeImmutable
152
+ * @param \ DateTimeImmutable $timestamp Timestamp.
153
+ * @return \ DateTimeImmutable
156
154
*/
157
155
private function refreshTokenLifeTime (DateTimeImmutable $ timestamp ): DateTimeImmutable
158
156
{
159
157
$ refreshTokenLifeTime = Configure::read ('Api.Jwt.RefreshToken.lifetime ' );
160
158
161
- return $ timestamp ->add (new DateInterval (" PT " . $ refreshTokenLifeTime . " S " ));
159
+ return $ timestamp ->add (new DateInterval (' PT ' . $ refreshTokenLifeTime . ' S ' ));
162
160
}
163
161
}
0 commit comments