2023-06-19 23:42:47 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2020-03-02 02:38:29 +01:00
|
|
|
|
2023-08-11 04:46:45 +02:00
|
|
|
package model // import "miniflux.app/v2/internal/model"
|
2020-03-02 02:38:29 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-08-11 04:46:45 +02:00
|
|
|
"miniflux.app/v2/internal/crypto"
|
2020-03-02 02:38:29 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// APIKey represents an application API key.
|
|
|
|
type APIKey struct {
|
|
|
|
ID int64
|
|
|
|
UserID int64
|
|
|
|
Token string
|
|
|
|
Description string
|
|
|
|
LastUsedAt *time.Time
|
|
|
|
CreatedAt time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewAPIKey initializes a new APIKey.
|
|
|
|
func NewAPIKey(userID int64, description string) *APIKey {
|
|
|
|
return &APIKey{
|
|
|
|
UserID: userID,
|
|
|
|
Token: crypto.GenerateRandomString(32),
|
|
|
|
Description: description,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// APIKeys represents a collection of API Key.
|
|
|
|
type APIKeys []*APIKey
|