🐛 Fix api key missing account id
This commit is contained in:
@ -8,4 +8,6 @@ type ApiKey struct {
|
||||
Lifecycle *int64 `json:"lifecycle"`
|
||||
Ticket AuthTicket `json:"ticket" gorm:"TicketID"`
|
||||
TicketID uint `json:"ticket_id"`
|
||||
Account Account `json:"account"`
|
||||
AccountID uint `json:"account_id"`
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import (
|
||||
)
|
||||
|
||||
func NewApiKey(user models.Account, key models.ApiKey, ip, ua string, claims []string) (models.ApiKey, error) {
|
||||
key.Account = user
|
||||
key.AccountID = user.ID
|
||||
|
||||
var expiredAt *time.Time
|
||||
if key.Lifecycle != nil {
|
||||
expiredAt = lo.ToPtr(time.Now().Add(time.Duration(*key.Lifecycle) * time.Second))
|
||||
|
Reference in New Issue
Block a user