🐛 Fix api key missing account id

This commit is contained in:
2024-08-25 23:15:29 +08:00
parent b097dab9e1
commit 46c7b6dff1
3 changed files with 10 additions and 4 deletions

View File

@ -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"`
}

View File

@ -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))