usecase

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Usecase

type Usecase[T user.Model] struct {
	// contains filtered or unexported fields
}

Usecase provides social auth business logic. It depends only on user.Model — no Email or Password trait constraints.

func New

func New[T user.Model](
	socAccountRepo socialauth.Repository,
	userRepo user.Repository[T],
	opts ...UsecaseOption[T],
) *Usecase[T]

New creates a socialauth Usecase.

  • socAccountRepo — social account repository
  • userRepo — user repository used by the default provisioning flow
  • opts — optional UsecaseOption values (e.g. WithUserProvisioner)

func (*Usecase[T]) Get

Get social account by id.

func (*Usecase[T]) List

List social accounts by filter.

func (*Usecase[T]) Register

func (u *Usecase[T]) Register(ctx context.Context, ownerObj user.Model, accountObj *socialAccountModels.AccountSocial) (uint64, error)

Register links the social account to an owner user.

If the owner user (ownerObj) has no ID yet, the provisioner (if configured) or the built-in default flow is used to find or create the owner:

  1. Custom provisioner → delegate entirely to SocialUserProvisioner.EnsureUser.
  2. Default flow: a. sessionUser is not anonymous → use it as owner. b. sessionUser is anonymous → create a minimal user via userRepo.Create.

func (*Usecase[T]) SetToken

func (u *Usecase[T]) SetToken(ctx context.Context, name string, accountSocialID uint64, token *elogin.Token) error

SetToken stores a social account token by name and account social ID.

func (*Usecase[T]) Token

func (u *Usecase[T]) Token(ctx context.Context, name string, accountSocialID uint64) (*elogin.Token, error)

Token returns social account token by name and account social ID.

func (*Usecase[T]) Update

func (u *Usecase[T]) Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error

Update social account by id.

type UsecaseOption added in v0.5.0

type UsecaseOption[T user.Model] func(*Usecase[T])

UsecaseOption configures the socialauth Usecase.

func WithUserProvisioner added in v0.5.0

func WithUserProvisioner[T user.Model](p socialauth.SocialUserProvisioner[T]) UsecaseOption[T]

WithUserProvisioner sets the optional user provisioner. If not set, the built-in default flow is used (see [SocialUserProvisioner]).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL