check / check (push) Waiting to run
Replaces #559, which conflicted. Model: opus-5-5
22 lines
646 B
Go
22 lines
646 B
Go
package database
|
|
|
|
import "time"
|
|
|
|
// APIKey represents an API key for a user.
|
|
//
|
|
// Key is a bearer credential, so it is never marshalled with the
|
|
// model. A creation handler that has to show it once returns it in its
|
|
// own response type.
|
|
type APIKey struct {
|
|
BaseModel
|
|
|
|
UserID string `gorm:"type:uuid;not null" json:"userId"`
|
|
Key string `gorm:"uniqueIndex;not null" json:"-"`
|
|
Description string `json:"description"`
|
|
LastUsedAt *time.Time `json:"lastUsedAt,omitempty"`
|
|
|
|
// Relations. No model marshals the record it belongs to:
|
|
// User.APIKeys leads back here, and the JSON could loop.
|
|
User User `json:"-"`
|
|
}
|