Documentation
¶
Index ¶
- Variables
- func GenerateToken() (string, error)
- type ChangePassword
- type ChangePasswordInput
- type ConfirmResetPasswordInput
- type DefaultMailSender
- type DefaultUserCreator
- type DefaultVerifiedEmailChecker
- type Login
- type LoginInput
- type MailSender
- type Register
- type RegisterInput
- type ResetPassword
- type ResetPasswordConfig
- type User
- type UserCreator
- type VerifiedEmailChecker
Constants ¶
This section is empty.
Variables ¶
var ErrCannotLogin = erruser.New(
"cannot login",
"Cannot log in automatically after registration. Please, try to log in yourself.",
)
var ErrEmailAlreadyExists = erruser.New(
"email already exists",
"Email already exists. Please log in using your password.",
)
var ErrInvalidPassword = erruser.New(
"invalid password",
"The password you entered is incorrect. Please try again.",
)
var ErrResetPasswordTokenNotFound = erruser.New(
"reset password token not found",
"The reset password link is invalid or has expired.",
)
var ErrUserAlreadyExists = erruser.New(
"user already exists",
"User with such email already exists. Please log in using another type of authentication.",
)
var ErrUserNotFound = errsys.New(
"user not found",
"The user with the provided email address does not exist.",
)
Functions ¶
func GenerateToken ¶
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 ConfirmResetPasswordInput ¶
type DefaultMailSender ¶
type DefaultMailSender struct {
// contains filtered or unexported fields
}
func (*DefaultMailSender) ResetPasswordEmail ¶
type DefaultUserCreator ¶
type DefaultUserCreator struct {
// contains filtered or unexported fields
}
func (*DefaultUserCreator) CreateUser ¶
type DefaultVerifiedEmailChecker ¶
type DefaultVerifiedEmailChecker struct {
}
func (*DefaultVerifiedEmailChecker) FindUserIDByVerifiedEmail ¶
type Login ¶
type Login struct {
// contains filtered or unexported fields
}
func NewLogin ¶
func NewLogin( passwordAuth *auth.PasswordAuthenticator, tokenAuth *auth.PlainTokenAuthenticator, ) *Login
func (*Login) Execute ¶
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 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 ¶
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 ResetPassword ¶
type ResetPassword struct {
// contains filtered or unexported fields
}
func NewResetPassword ¶
func NewResetPassword( config ResetPasswordConfig, identity repository.IdentityRepository, account repository.AccountRepository, resetPassword repository.ResetPasswordRequestRepository, mailer MailSender, credentials repository.CredentialRepository, emailChecker VerifiedEmailChecker, ) *ResetPassword
func (*ResetPassword) Confirm ¶
func (r *ResetPassword) Confirm(ctx context.Context, input ConfirmResetPasswordInput) error
func (*ResetPassword) Request ¶
func (r *ResetPassword) Request(ctx context.Context, email string) (repository.ResetPasswordRequest, error)
type ResetPasswordConfig ¶
type ResetPasswordConfig struct {
FrontendHost string `env:"FRONTEND_HOST" envDefault:"http://localhost:8001"`
}
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