Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
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):
- Look up AccountSocial by (provider, social_id).
- Found → load and return the existing user.
- Not found + sessionUser is not anonymous → use sessionUser as owner.
- Not found + sessionUser is anonymous → create a minimal user via user.Repository.Create and set its ID.
- 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.
Click to show internal directories.
Click to hide internal directories.