File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,13 @@ class Passport
6868 */
6969 public static $ refreshTokensExpireAt ;
7070
71+ /**
72+ * The date when personal access tokens expire.
73+ *
74+ * @var \DateTimeInterface|null
75+ */
76+ public static $ personAccessTokensExpireAt ;
77+
7178 /**
7279 * The name for API token cookies.
7380 *
@@ -315,6 +322,25 @@ public static function refreshTokensExpireIn(DateTimeInterface $date = null)
315322 return new static ;
316323 }
317324
325+ /**
326+ * Get or set when personal access tokens expire.
327+ *
328+ * @param \DateTimeInterface|null $date
329+ * @return \DateInterval|static
330+ */
331+ public static function personalAccessTokensExpireIn (DateTimeInterface $ date = null )
332+ {
333+ if (is_null ($ date )) {
334+ return static ::$ personAccessTokensExpireAt
335+ ? Carbon::now ()->diff (static ::$ personAccessTokensExpireAt )
336+ : new DateInterval ('P1Y ' );
337+ }
338+
339+ static ::$ personAccessTokensExpireAt = $ date ;
340+
341+ return new static ;
342+ }
343+
318344 /**
319345 * Get or set the name for API token cookies.
320346 *
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ protected function registerAuthorizationServer()
111111 );
112112
113113 $ server ->enableGrantType (
114- new PersonalAccessGrant , new DateInterval ( ' P1Y ' )
114+ new PersonalAccessGrant , Passport:: personalAccessTokensExpireIn ( )
115115 );
116116
117117 $ server ->enableGrantType (
You can’t perform that action at this time.
0 commit comments