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: 18 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

This section is empty.

Variables

View Source
var ErrCannotLogin = erruser.New(
	"cannot login",
	"Cannot log in automatically after registration. Please, try to log in yourself.",
)
View Source
var ErrEmailAlreadyExists = erruser.New(
	"email already exists",
	"Email already exists. Please log in using your password.",
)
View Source
var ErrInvalidPassword = erruser.New(
	"invalid password",
	"The password you entered is incorrect. Please try again.",
)
View Source
var ErrResetPasswordTokenNotFound = erruser.New(
	"reset password token not found",
	"The reset password link is invalid or has expired.",
)
View Source
var ErrUserAlreadyExists = erruser.New(
	"user already exists",
	"User with such email already exists. Please log in using another type of authentication.",
)
View Source
var ErrUserNotFound = errsys.New(
	"user not found",
	"The user with the provided email address does not exist.",
)

Functions

func GenerateToken

func GenerateToken() (string, error)

Types

type ChangePassword

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

func NewChangePassword

func NewChangePassword(credentialRepository repository.CredentialRepository) *ChangePassword

func (*ChangePassword) Execute

func (c *ChangePassword) Execute(
	ctx context.Context,
	performerID uuid.UUID,
	input ChangePasswordInput,
) error

type ChangePasswordInput

type ChangePasswordInput struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`
}

func (*ChangePasswordInput) Validate

func (i *ChangePasswordInput) Validate(ctx context.Context) error

type ConfirmResetPasswordInput

type ConfirmResetPasswordInput struct {
	Token    string `json:"token"`
	Password string `json:"password"`
}

func (*ConfirmResetPasswordInput) Validate

type DefaultMailSender

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

func (*DefaultMailSender) ResetPasswordEmail

func (d *DefaultMailSender) ResetPasswordEmail(
	ctx context.Context,
	to string,
	resetPasswordLink string,
) error

type DefaultUserCreator

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

func (*DefaultUserCreator) CreateUser

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

type DefaultVerifiedEmailChecker

type DefaultVerifiedEmailChecker struct {
}

func (*DefaultVerifiedEmailChecker) FindUserIDByVerifiedEmail

func (d *DefaultVerifiedEmailChecker) FindUserIDByVerifiedEmail(ctx context.Context, email string) (uuid.UUID, error)

type Login

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

func NewLogin

func NewLogin(
	passwordAuth *auth.PasswordAuthenticator,
	tokenAuth *auth.PlainTokenAuthenticator,
) *Login

func (*Login) Execute

func (l *Login) Execute(ctx context.Context, input LoginInput) (auth.TokenPair, error)

Execute performs the login action by email and password. Returns a token pair of the access and refresh tokens if the login is successful. Errors: * github.com/go-modulus/auth.ErrIdentityIsBlocked - if the identity is blocked. * github.com/go-modulus/auth.ErrInvalidPassword - if the password is invalid. * github.com/go-modulus/auth.ErrInvalidIdentity - if identity is not found in the repository.

type LoginInput

type LoginInput struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (*LoginInput) Validate

func (i *LoginInput) Validate(ctx context.Context) error

type MailSender

type MailSender interface {
	ResetPasswordEmail(
		ctx context.Context,
		to string,
		resetPasswordLink string,
	) error
}

func NewDefaultMailSender

func NewDefaultMailSender(logger *slog.Logger) MailSender

type Register

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

func NewRegister

func NewRegister(
	passwordAuth *auth.PasswordAuthenticator,
	identityRepository repository.IdentityRepository,
	accountRepository repository.AccountRepository,
	userCreator UserCreator,
	login *Login,
) *Register

func (*Register) Execute

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

Execute performs the register action by email and password. It returns the registered user.

Errors: * ErrEmailAlreadyExists - the identity with such email already exists. * ErrUserAlreadyExists - overridden user provider says that the user already exists. * ErrCannotLogin - cannot log in automatically after registration.

type RegisterInput

type RegisterInput struct {
	// ID of created user
	// It is used to create a new account. In a case of empty ID, it will be generated automatically.
	ID       uuid.UUID
	Email    string
	Password string
	UserInfo map[string]interface{}
	Roles    []string
}

func (*RegisterInput) Validate

func (i *RegisterInput) Validate(ctx context.Context) error

type ResetPassword

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

func (*ResetPassword) Confirm

func (*ResetPassword) Request

type ResetPasswordConfig

type ResetPasswordConfig struct {
	FrontendHost string `env:"FRONTEND_HOST" envDefault:"http://localhost:8001"`
}

type User

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

type UserCreator

type UserCreator interface {
	// CreateUser 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.
	CreateUser(ctx context.Context, user User) (User, error)
}

func NewDefaultUserCreator

func NewDefaultUserCreator(logger *slog.Logger) UserCreator

type VerifiedEmailChecker

type VerifiedEmailChecker interface {
	// FindUserIDByVerifiedEmail checks if the email is verified and returns the user ID.
	// If the email is not verified or not found, it returns ErrUserNotFound.
	FindUserIDByVerifiedEmail(ctx context.Context, email string) (uuid.UUID, error)
}

func NewDefaultVerifiedEmailChecker

func NewDefaultVerifiedEmailChecker() VerifiedEmailChecker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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