mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Added possibility to list all available API keys at the user settings page
This commit is contained in:
parent
040e86ea6d
commit
35a0e8464a
9 changed files with 245 additions and 42 deletions
|
@ -72,7 +72,7 @@ class ApiToken
|
|||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
#[Groups('token:read')]
|
||||
private ?\DateTimeInterface $valid_until = null;
|
||||
private ?\DateTimeInterface $valid_until;
|
||||
|
||||
#[ORM\Column(length: 68, unique: true)]
|
||||
private string $token;
|
||||
|
@ -89,6 +89,9 @@ class ApiToken
|
|||
{
|
||||
// Generate a rondom token on creation. The tokenType is 3 characters long (plus underscore), so the token is 68 characters long.
|
||||
$this->token = $tokenType->getTokenPrefix() . bin2hex(random_bytes(32));
|
||||
|
||||
//By default, tokens are valid for 1 year.
|
||||
$this->valid_until = new \DateTime('+1 year');
|
||||
}
|
||||
|
||||
public function getTokenType(): ApiTokenType
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue