X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/3de55ee6454667e2d4b3cb866625a165ccb9aee3..refs/pull/3598/head:/app/Api/ApiToken.php diff --git a/app/Api/ApiToken.php b/app/Api/ApiToken.php index cdcb33a7b..70b289ae1 100644 --- a/app/Api/ApiToken.php +++ b/app/Api/ApiToken.php @@ -1,14 +1,28 @@ - 'date:Y-m-d' + 'expires_at' => 'date:Y-m-d', ]; /** @@ -18,4 +32,21 @@ class ApiToken extends Model { return $this->belongsTo(User::class); } + + /** + * Get the default expiry value for an API token. + * Set to 100 years from now. + */ + public static function defaultExpiry(): string + { + return Carbon::now()->addYears(100)->format('Y-m-d'); + } + + /** + * {@inheritdoc} + */ + public function logDescriptor(): string + { + return "({$this->id}) {$this->name}; User: {$this->user->logDescriptor()}"; + } }