Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ class Passport
*/
public static $refreshTokensExpireAt;

/**
* The date when personal access tokens expire.
*
* @var \DateTimeInterface|null
*/
public static $personAccessTokensExpireAt;

/**
* The name for API token cookies.
*
Expand Down Expand Up @@ -315,6 +322,25 @@ public static function refreshTokensExpireIn(DateTimeInterface $date = null)
return new static;
}

/**
* Get or set when personal access tokens expire.
*
* @param \DateTimeInterface|null $date
* @return \DateInterval|static
*/
public static function personalAccessTokensExpireIn(DateTimeInterface $date = null)
{
if (is_null($date)) {
return static::$personAccessTokensExpireAt
? Carbon::now()->diff(static::$personAccessTokensExpireAt)
: new DateInterval('P1Y');
}

static::$personAccessTokensExpireAt = $date;

return new static;
}

/**
* Get or set the name for API token cookies.
*
Expand Down
2 changes: 1 addition & 1 deletion src/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function registerAuthorizationServer()
);

$server->enableGrantType(
new PersonalAccessGrant, new DateInterval('P1Y')
new PersonalAccessGrant, Passport::personalAccessTokensExpireIn()
);

$server->enableGrantType(
Expand Down