Some checks are pending
Release Binaries / Build and Release (.exe, amd64, windows, windows-amd64) (push) Waiting to run
Release Binaries / Build and Release (amd64, darwin, darwin-amd64) (push) Waiting to run
Release Binaries / Build and Release (amd64, linux, linux-amd64) (push) Waiting to run
Release Binaries / Build and Release (arm64, darwin, darwin-arm64) (push) Waiting to run
Release Binaries / Build and Release (arm64, linux, linux-arm64) (push) Waiting to run
- Remove Role association field from User model - Remove User association field from Token model - controller/user.go: query Role separately after loading User - controller/token.go: query User and Role with separate DB calls - handler/admin.go: introduce userResp type, build role info manually; batch-load roles in AdminListUsers to avoid N+1 🤖 Generated with [Qoder][https://qoder.com]
19 lines
641 B
Go
19 lines
641 B
Go
package model
|
|
|
|
import "time"
|
|
|
|
// Token is a personal API token for programmatic file upload.
|
|
// Token values are prefixed with "ust_" to distinguish them from session tokens.
|
|
type Token struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
UserID uint `gorm:"not null;index" json:"user_id"`
|
|
Name string `gorm:"not null" json:"name"`
|
|
Token string `gorm:"uniqueIndex;not null" json:"-"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
LastUsedAt *time.Time `json:"last_used_at"`
|
|
ExpiresAt *time.Time `json:"expires_at"`
|
|
}
|
|
|
|
// TokenPrefix is the prefix for all API token values.
|
|
const TokenPrefix = "ust_"
|