forgotpassword

package
v0.0.0-...-122f59b Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Service), "*"),
	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 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 {
	List(userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error)
	New(spec *authenticator.Spec) (*authenticator.Info, error)
	WithSpec(ai *authenticator.Info, spec *authenticator.Spec) (bool, *authenticator.Info, error)
	Update(info *authenticator.Info) error
	Create(authenticatorInfo *authenticator.Info, markVerified bool) error
	Delete(info *authenticator.Info) error
}

type CodeChannel

type CodeChannel string
const (
	CodeChannelUnknown  CodeChannel = ""
	CodeChannelEmail    CodeChannel = "email"
	CodeChannelWhatsapp CodeChannel = "whatsapp"
	CodeChannelSMS      CodeChannel = "sms"
)

type CodeKind

type CodeKind string
const (
	CodeKindUnknown   CodeKind = ""
	CodeKindLink      CodeKind = "CodeKindLink"
	CodeKindShortCode CodeKind = "CodeKindShortCode"
)

type CodeOptions

type CodeOptions struct {
	AuthenticationFlowType        string
	AuthenticationFlowName        string
	AuthenticationFlowJSONPointer jsonpointer.T
	Kind                          CodeKind
	Channel                       CodeChannel
}

type IdentityService

type IdentityService interface {
	ListByClaim(name string, value string) ([]*identity.Info, error)
}

type Logger

type Logger struct{ *log.Logger }

func NewLogger

func NewLogger(lf *log.Factory) Logger

type OTPCodeService

type OTPCodeService interface {
	GenerateOTP(kind otp.Kind, target string, form otp.Form, opt *otp.GenerateOptions) (string, error)
	VerifyOTP(kind otp.Kind, target string, otp string, opts *otp.VerifyOptions) error
	InspectState(kind otp.Kind, target string) (*otp.State, error)
	LookupCode(purpose otp.Purpose, code string) (target string, err error)
	ConsumeCode(purpose otp.Purpose, target string) error
}

type OTPSender

type OTPSender interface {
	Prepare(channel model.AuthenticatorOOBChannel, target string, form otp.Form, typ otp.MessageType) (*otp.PreparedMessage, error)
	Send(msg *otp.PreparedMessage, opts otp.SendOptions) error
}

type Service

type Service struct {
	Logger        Logger
	Config        *config.AppConfig
	FeatureConfig *config.FeatureConfig

	Identities     IdentityService
	Authenticators AuthenticatorService
	OTPCodes       OTPCodeService
	OTPSender      OTPSender
}

func (*Service) CodeLength

func (s *Service) CodeLength(target string, channel CodeChannel, kind CodeKind) int

func (*Service) InspectState

func (s *Service) InspectState(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 (s *Service) IsRateLimitError(err error, target string, channel CodeChannel, kind CodeKind) bool

func (*Service) ResetPassword

func (s *Service) ResetPassword(code string, newPassword string) error

ResetPassword 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(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

func (s *Service) SendCode(loginID string, options *CodeOptions) error

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) SetPassword

func (s *Service) SetPassword(userID string, newPassword string) (err error)

SetPassword ensures the user identified by userID has the specified password. It perform necessary mutation to make this happens.

func (*Service) VerifyCode

func (s *Service) VerifyCode(code string) (state *otp.State, err error)

func (*Service) VerifyCodeWithTarget

func (s *Service) VerifyCodeWithTarget(target string, code string, codeChannel CodeChannel, kind CodeKind) (state *otp.State, err error)

Jump to

Keyboard shortcuts

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