package oauth2 import ( "context" "errors" "github.com/go-oauth2/oauth2/v4" "github.com/go-oauth2/oauth2/v4/models" "gorm.io/gorm" "nucleus/internal/entities" ) type ClientStore struct{} func (c *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error) { db, ok := ctx.Value("db").(*gorm.DB) if !ok { return nil, errors.New("missing database object") } var client entities.Client err := db.First(&client, "id=?", id).Error if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return nil, errors.New("no client found") } return nil, err } return &models.Client{ ID: client.AccessKey, Secret: client.SecretKey, Domain: client.Domain, Public: client.Public, //UserID: "", }, nil }