feat(identity): confirm the email address with a six-digit code from the message
This commit is contained in:
1 parent
c94434cd09
commit
d365a05c96
87 files changed
+4764
-224
No files matched your search
@@ -31,11 +31,14 @@ type ConfirmationDependencies struct {
|
||||
Metrics RateLimitMetrics
|
||||
}
|
||||
|
||||
// ConfirmationSettings contains the attempt limits for one token and one
|
||||
// client. The client limit matches registration and resend.
|
||||
// ConfirmationSettings contains the attempt limits for one token, one client,
|
||||
// and one normalized address. The client limit matches registration and
|
||||
// resend. The address limit is the login limit: code confirmation draws on the
|
||||
// same hourly budget as login for the address.
|
||||
type ConfirmationSettings struct {
|
||||
TokenHourlyLimit int64
|
||||
ClientHourlyLimit int64
|
||||
EmailHourlyLimit int64
|
||||
}
|
||||
|
||||
// EmailConfirmation confirms the address and applies the credentials of the
|
||||
@@ -52,7 +55,7 @@ func NewEmailConfirmation(deps ConfirmationDependencies, settings ConfirmationSe
|
||||
case deps.Transactor == nil, deps.Tokens == nil, deps.Credentials == nil,
|
||||
deps.Limiter == nil, deps.Keyring == nil, deps.Clock == nil:
|
||||
return nil, errors.New("identity.NewEmailConfirmation - every dependency must be set")
|
||||
case settings.TokenHourlyLimit < 1, settings.ClientHourlyLimit < 1:
|
||||
case settings.TokenHourlyLimit < 1, settings.ClientHourlyLimit < 1, settings.EmailHourlyLimit < 1:
|
||||
return nil, errors.New("identity.NewEmailConfirmation - confirmation limits must be positive")
|
||||
}
|
||||
return &EmailConfirmation{deps: deps, settings: settings}, nil
|
||||
@@ -114,6 +117,8 @@ func (confirmation *EmailConfirmation) Confirm(ctx context.Context, command Conf
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// confirmationOutcomeError maps the storage outcome of a link confirmation to
|
||||
// the public refusals. Expiry is reported as its own refusal.
|
||||
func confirmationOutcomeError(err error) error {
|
||||
switch {
|
||||
case errors.Is(err, outbound.ErrEmailTokenExpired):
|
||||
|
||||
Reference in new issue
Block a user