🐛 Fix api key missing account id
This commit is contained in:
parent
b097dab9e1
commit
46c7b6dff1
9
.idea/workspace.xml
generated
9
.idea/workspace.xml
generated
@ -4,9 +4,10 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix path parameters misplaced">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix api key wasn't in auto maintain range">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/bot.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/bot.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/bot_token.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/bot_token.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -153,7 +154,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value=":recycle: Refactored relation system :arrow_up: Support new realm & relation api" />
|
|
||||||
<MESSAGE value=":bug: Fix model relation issue" />
|
<MESSAGE value=":bug: Fix model relation issue" />
|
||||||
<MESSAGE value=":arrow_up: Upgrade dealer" />
|
<MESSAGE value=":arrow_up: Upgrade dealer" />
|
||||||
<MESSAGE value=":sparkles: Support stream controller event emit" />
|
<MESSAGE value=":sparkles: Support stream controller event emit" />
|
||||||
@ -178,7 +178,8 @@
|
|||||||
<MESSAGE value=":sparkles: Bot related bot key apis" />
|
<MESSAGE value=":sparkles: Bot related bot key apis" />
|
||||||
<MESSAGE value=":bug: Fix bot related bot key apis path error" />
|
<MESSAGE value=":bug: Fix bot related bot key apis path error" />
|
||||||
<MESSAGE value=":bug: Fix path parameters misplaced" />
|
<MESSAGE value=":bug: Fix path parameters misplaced" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix path parameters misplaced" />
|
<MESSAGE value=":bug: Fix api key wasn't in auto maintain range" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix api key wasn't in auto maintain range" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
@ -8,4 +8,6 @@ type ApiKey struct {
|
|||||||
Lifecycle *int64 `json:"lifecycle"`
|
Lifecycle *int64 `json:"lifecycle"`
|
||||||
Ticket AuthTicket `json:"ticket" gorm:"TicketID"`
|
Ticket AuthTicket `json:"ticket" gorm:"TicketID"`
|
||||||
TicketID uint `json:"ticket_id"`
|
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) {
|
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
|
var expiredAt *time.Time
|
||||||
if key.Lifecycle != nil {
|
if key.Lifecycle != nil {
|
||||||
expiredAt = lo.ToPtr(time.Now().Add(time.Duration(*key.Lifecycle) * time.Second))
|
expiredAt = lo.ToPtr(time.Now().Add(time.Duration(*key.Lifecycle) * time.Second))
|
||||||
|
Loading…
Reference in New Issue
Block a user