socialauth

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	UserID          []uint64
	SocialID        []string
	Provider        []string
	Email           []string
	RetrieveDeleted bool
}

func (*Filter) PrepareQuery

func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB

type Repository

type Repository interface {
	Get(ctx context.Context, id uint64) (*socialAccountModels.AccountSocial, error)
	List(ctx context.Context, filter *Filter) ([]*socialAccountModels.AccountSocial, error)
	Create(ctx context.Context, account *socialAccountModels.AccountSocial) (uint64, error)
	Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error
	Token(ctx context.Context, name string, accountSocialID uint64) (*elogin.Token, error)
	SetToken(ctx context.Context, name string, accountSocialID uint64, token *elogin.Token) error
}

type SocialUserProvisioner added in v0.5.0

type SocialUserProvisioner[TUser user.Model] interface {
	// EnsureUser returns the owner user for the given social login.
	// sessionUser is the currently logged-in user from the request context
	// (may be anonymous).  provider is the OAuth2 provider name.
	// data contains the profile information returned by the OAuth2 provider.
	EnsureUser(ctx context.Context, sessionUser TUser, provider string, data *elogin.UserData) (TUser, error)
}

SocialUserProvisioner is an optional hook that determines or creates the owner user for a social login callback.

When injected into the socialauth usecase via [WithUserProvisioner], the provisioner is called during Usecase.Register instead of the built-in default flow. If no provisioner is set the default flow runs automatically.

Default flow (provisioner == nil):

  1. Look up AccountSocial by (provider, social_id).
  2. Found → load and return the existing user.
  3. Not found + sessionUser is not anonymous → use sessionUser as owner.
  4. Not found + sessionUser is anonymous → create a minimal user via user.Repository.Create and set its ID.
  5. Always save AccountSocial.UserID = owner.GetID().

type Usecase

type Usecase interface {
	Get(ctx context.Context, id uint64) (*socialAccountModels.AccountSocial, error)
	List(ctx context.Context, filter *Filter) ([]*socialAccountModels.AccountSocial, error)
	Register(ctx context.Context, owner user.Model, account *socialAccountModels.AccountSocial) (uint64, error)
	Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error
	Token(ctx context.Context, name string, accountSocialID uint64) (*elogin.Token, error)
	SetToken(ctx context.Context, name string, accountSocialID uint64, token *elogin.Token) error
}

Usecase of the socialauth account which provides business logic for social auth and connection to the user account by social network.

Directories

Path Synopsis
delivery

Jump to

Keyboard shortcuts

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