Files
sm-user-plugin/models/oauth_identity.go
Jakub Zych 63ac504c42 feat(14.1-01): add OAuth identities table and empty-list Index
- Model golem15_user_oauth_identities with Encrypted tokens and empty Fillable
- gormigrate 202610050001 with both unique indexes, cascade FK, and jsonb profile_data
- OAuthIdentitiesIndex returns {"data":[]} for a signed-in caller with no rows
2026-10-05 21:09:28 +02:00

33 lines
1.3 KiB
Go

package models
import (
"time"
"git.golem15.com/golem15/summercms/modules/lagoon"
)
// OAuthIdentity is one linked social-login provider for a user.
type OAuthIdentity struct {
ID uint `gorm:"column:id;primaryKey"`
UserID uint `gorm:"column:user_id"`
Provider string `gorm:"column:provider"`
ProviderID string `gorm:"column:provider_id"`
AccessToken lagoon.Encrypted `gorm:"column:access_token" json:"-"`
RefreshToken lagoon.Encrypted `gorm:"column:refresh_token" json:"-"`
TokenExpiresAt *time.Time `gorm:"column:token_expires_at"`
ProfileData lagoon.Jsonable[map[string]any] `gorm:"column:profile_data"`
LinkedAt *time.Time `gorm:"column:linked_at"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (OAuthIdentity) TableName() string { return "golem15_user_oauth_identities" }
func (OAuthIdentity) Fillable() []string { return []string{} }
func (OAuthIdentity) Hidden() []string {
return []string{"access_token", "refresh_token", "profile_data"}
}
func init() { Register(OAuthIdentity{}) }