action

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const IdentityTypeGoogle = "google"

Variables

View Source
var ErrAccountIsBlocked = errsys.New("account is blocked", "Your account is blocked. Please contact support.")
View Source
var ErrFailedToExchangeToken = errsys.New(
	"failed to exchange token",
	"There is an issue to exchange Google token. Please try again later or contact support",
)
View Source
var ErrFailedToGetUserInfo = errsys.New(
	"failed to get user info",
	"There is an issue to get user info from Google. Please try again later",
)
View Source
var ErrInvalidIdentity = errsys.New(
	"invalid identity",
	"The Google registration is broken. We cannot authenticate you at the moment. Please try again later or use another type of registration.",
)
View Source
var ErrUserAlreadyExists = erruser.New(
	"user already exists",
	"User with such email already exists. Please log in using another type of authentication.",
)

Functions

This section is empty.

Types

type DefaultUserCreator

type DefaultUserCreator struct {
	// contains filtered or unexported fields
}

func (*DefaultUserCreator) CreateUserFromGoogle

func (c *DefaultUserCreator) CreateUserFromGoogle(ctx context.Context, user User) (User, error)

type GoogleConfig

type GoogleConfig struct {
	RedirectUrl  string   `env:"AUTH_GOOGLE_REDIRECT_URL, default=http://localhost:8001/auth/google/callback"`
	ClientID     string   `env:"AUTH_GOOGLE_CLIENT_ID"`
	ClientSecret string   `env:"AUTH_GOOGLE_SECRET"`
	Scopes       []string `env:"AUTH_GOOGLE_SCOPES, default=openid,email,profile"`
}

type GoogleUser

type GoogleUser struct {
	ID            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Picture       string `json:"picture"`
	Locale        string `json:"locale"`
}

type Register

type Register struct {
	// contains filtered or unexported fields
}

func NewRegister

func NewRegister(
	config GoogleConfig,
	plainTokenAuth *auth.PlainTokenAuthenticator,
	identityRepository repository.IdentityRepository,
	accountRepository repository.AccountRepository,
	creator UserCreator,
) *Register

func (*Register) Execute

func (r *Register) Execute(ctx context.Context, input RegisterInput) (auth.TokenPair, error)

type RegisterInput

type RegisterInput struct {
	Code        string                 `json:"code"`
	Verifier    string                 `json:"verifier"`
	RedirectUrl string                 `json:"redirectUrl"`
	Roles       []string               `json:"roles"`
	UserInfo    map[string]interface{} `json:"userInfo"`
}

type User

type User struct {
	ID                          uuid.UUID
	Email                       string
	GoogleUser                  GoogleUser
	UserInfo                    map[string]interface{}
	SubscribedToMarketingEmails bool
}

type UserCreator

type UserCreator interface {
	// CreateUserFromGoogle creates a new user with id and email.
	// It returns the created user.
	// Errors:
	// * ErrUserAlreadyExists - if the user already exists. In a case of this error it should return the existing user.
	CreateUserFromGoogle(ctx context.Context, user User) (User, error)
}

func NewDefaultUserCreator

func NewDefaultUserCreator(logger *slog.Logger) UserCreator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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