Documentation ¶
Index ¶
- Variables
- type AuthenticatorService
- type CodeChannel
- type CodeKind
- type CodeOptions
- type EventService
- type IdentityService
- type Logger
- type OTPCodeService
- type OTPSender
- type Sender
- type SenderService
- type Service
- func (s *Service) ChangePasswordByAdmin(ctx context.Context, options *SetPasswordOptions) error
- func (s *Service) CodeLength(target string, channel CodeChannel, kind CodeKind) int
- func (s *Service) InspectState(ctx context.Context, target string, channel CodeChannel, kind CodeKind) (*otp.State, error)
- func (s *Service) IsRateLimitError(err error, target string, channel CodeChannel, kind CodeKind) bool
- func (s *Service) ResetPasswordByEndUser(ctx context.Context, code string, newPassword string) error
- func (s *Service) ResetPasswordWithTarget(ctx context.Context, target string, code string, newPassword string, ...) error
- func (s *Service) SendCode(ctx context.Context, loginID string, options *CodeOptions) error
- func (s *Service) VerifyCode(ctx context.Context, code string) (state *otp.State, err error)
- func (s *Service) VerifyCodeWithTarget(ctx context.Context, target string, code string, codeChannel CodeChannel, ...) (state *otp.State, err error)
- type SetPasswordOptions
- type TranslationService
Constants ¶
This section is empty.
Variables ¶
View Source
var DependencySet = wire.NewSet( wire.Struct(new(Service), "*"), wire.Struct(new(Sender), "*"), NewLogger, )
View Source
var ErrFeatureDisabled = SendCodeFailed.NewWithCause("forgot password is disabled", apierrors.StringCause("FeatureDisabled"))
View Source
var ErrInvalidCode = PasswordResetFailed.NewWithCause("invalid code", apierrors.StringCause("InvalidCode"))
View Source
var ErrSendPasswordNoTarget = apierrors.Invalid.WithReason("SendPasswordNoTarget").New("no target to send the password")
View Source
var ErrUsedCode = PasswordResetFailed.NewWithCause("used code", apierrors.StringCause("UsedCode"))
View Source
var ErrUserNotFound = SendCodeFailed.NewWithCause("specified user not found", apierrors.StringCause("UserNotFound"))
View Source
var PasswordResetFailed = apierrors.Invalid.WithReason("PasswordResetFailed")
View Source
var SendCodeFailed = apierrors.Invalid.WithReason("ForgotPasswordFailed")
Functions ¶
This section is empty.
Types ¶
type AuthenticatorService ¶
type AuthenticatorService interface { New(ctx context.Context, spec *authenticator.Spec) (*authenticator.Info, error) UpdatePassword(ctx context.Context, info *authenticator.Info, options *service.UpdatePasswordOptions) (bool, *authenticator.Info, error) List(ctx context.Context, userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error) Update(ctx context.Context, info *authenticator.Info) error Create(ctx context.Context, authenticatorInfo *authenticator.Info, markVerified bool) error Delete(ctx context.Context, info *authenticator.Info) error }
type CodeChannel ¶
type CodeChannel string
const ( CodeChannelUnknown CodeChannel = "" CodeChannelEmail CodeChannel = "email" CodeChannelWhatsapp CodeChannel = "whatsapp" CodeChannelSMS CodeChannel = "sms" )
type CodeOptions ¶
type CodeOptions struct { AuthenticationFlowType string AuthenticationFlowName string AuthenticationFlowJSONPointer jsonpointer.T Kind CodeKind Channel CodeChannel IsAdminAPIResetPassword bool }
type EventService ¶
type IdentityService ¶
type OTPCodeService ¶
type OTPCodeService interface { GenerateOTP(ctx context.Context, kind otp.Kind, target string, form otp.Form, opt *otp.GenerateOptions) (string, error) VerifyOTP(ctx context.Context, kind otp.Kind, target string, otp string, opts *otp.VerifyOptions) error InspectState(ctx context.Context, kind otp.Kind, target string) (*otp.State, error) LookupCode(ctx context.Context, purpose otp.Purpose, code string) (target string, err error) ConsumeCode(ctx context.Context, purpose otp.Purpose, target string) error }
type Sender ¶
type Sender struct { AppConfg *config.AppConfig Identities IdentityService Sender SenderService Translation TranslationService }
func (*Sender) Send ¶
func (s *Sender) Send(ctx context.Context, userID string, password string, msgType translation.MessageType) error
type SenderService ¶
type SenderService interface {
SendEmailInNewGoroutine(ctx context.Context, msgType translation.MessageType, opts *mail.SendOptions) error
}
type Service ¶
type Service struct { Logger Logger Config *config.AppConfig FeatureConfig *config.FeatureConfig Identities IdentityService Authenticators AuthenticatorService OTPCodes OTPCodeService OTPSender OTPSender PasswordSender Sender Events EventService }
func (*Service) ChangePasswordByAdmin ¶
func (s *Service) ChangePasswordByAdmin(ctx context.Context, options *SetPasswordOptions) error
func (*Service) CodeLength ¶
func (s *Service) CodeLength(target string, channel CodeChannel, kind CodeKind) int
func (*Service) InspectState ¶
func (s *Service) InspectState(ctx context.Context, target string, channel CodeChannel, kind CodeKind) (*otp.State, error)
InspectState is for external use. It DOES NOT report dummy code as invalid.
func (*Service) IsRateLimitError ¶
func (*Service) ResetPasswordByEndUser ¶
func (s *Service) ResetPasswordByEndUser(ctx context.Context, code string, newPassword string) error
ResetPasswordByEndUser consumes code and reset password to newPassword. If the code is valid, the password is reset to newPassword. newPassword is checked against the password policy so password policy error may also be returned.
func (*Service) ResetPasswordWithTarget ¶
func (s *Service) ResetPasswordWithTarget(ctx context.Context, target string, code string, newPassword string, channel CodeChannel, kind CodeKind) error
ResetPasswordWithTarget is same as ResetPassword, except target is passed by caller.
func (*Service) SendCode ¶
SendCode uses loginID to look up Email Login IDs and Phone Number Login IDs. For each looked up login ID, a code is generated and delivered asynchronously.
func (*Service) VerifyCode ¶
type SetPasswordOptions ¶
type TranslationService ¶
type TranslationService interface {
EmailMessageData(ctx context.Context, msg *translation.MessageSpec, variables *translation.PartialTemplateVariables) (*translation.EmailMessageData, error)
}
Click to show internal directories.
Click to hide internal directories.