更新依赖项,添加单元测试,优化用户信息和令牌管理功能,增强中间件以支持 JWT 验证,新增访问令牌模型并更新数据库迁移。
This commit is contained in:
22
models/access_token.go
Normal file
22
models/access_token.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// AccessToken 表示 OAuth2 访问令牌
|
||||
type AccessToken struct {
|
||||
gorm.Model
|
||||
Token string `gorm:"uniqueIndex;not null"`
|
||||
UserID uint `gorm:"not null"`
|
||||
ClientID string `gorm:"not null"`
|
||||
Scope string `gorm:"type:text"`
|
||||
ExpiresAt time.Time `gorm:"not null"`
|
||||
IsRevoked bool `gorm:"default:false"`
|
||||
}
|
||||
|
||||
func (t *AccessToken) TableName() string {
|
||||
return "oauth_access_tokens"
|
||||
}
|
||||
Reference in New Issue
Block a user