Add names to API tokens.
This commit is contained in:
@@ -30,14 +30,15 @@ class API_apitoken extends API
|
||||
|
||||
$api_token = bin2hex(random_bytes(64 / 2));
|
||||
|
||||
|
||||
$api_token_hash = password_hash($api_token, PASSWORD_BCRYPT, ["cost" => 12]);
|
||||
$api_token_expiration_timestamp = strtotime('+1 year');
|
||||
$query = "INSERT INTO system_api_tokens (api_token_uuid, user_uuid, api_token, api_token_expiration_timestamp, api_token_created_timestamp) VALUES (UUID(), ?, ?, ?, ?)";
|
||||
|
||||
$api_token_name = $this->data['api_token_name'] ?? null;
|
||||
$query = "INSERT INTO system_api_tokens (api_token_uuid, user_uuid, api_token, api_token_name, api_token_expiration_timestamp, api_token_created_timestamp) VALUES (UUID(), ?, ?, ?, ?, ?)";
|
||||
$stmt = $this->prepareStatement($query);
|
||||
|
||||
$stmt->bind_param('ssii', $this->data['user_uuid'], $api_token_hash, $api_token_expiration_timestamp, time());
|
||||
$created_timestamp = time();
|
||||
|
||||
$stmt->bind_param('sssii', $this->data['user_uuid'], $api_token_hash, $api_token_name, $api_token_expiration_timestamp, $created_timestamp);
|
||||
|
||||
$this->executeStatement($stmt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user