Connect sign-up to Sendico Facts intake (#46)
This commit is contained in:
1 parent
30f0455122
commit
a584c8189a
40 files changed
+1616
-35
No files matched your search
@@ -119,6 +119,17 @@ func (s *service) CreateAccount(
|
||||
ctx context.Context,
|
||||
acct *customermodel.Account,
|
||||
) (string, error) {
|
||||
return s.createAccount(ctx, acct, "")
|
||||
}
|
||||
|
||||
func (s *service) CreateAccountWithActivationKey(ctx context.Context, acct *customermodel.Account, key string) (string, error) {
|
||||
if len(key) < 32 || len(key) > 128 {
|
||||
return "", merrors.InvalidArgument("server activation key required")
|
||||
}
|
||||
return s.createAccount(ctx, acct, key)
|
||||
}
|
||||
|
||||
func (s *service) createAccount(ctx context.Context, acct *customermodel.Account, key string) (string, error) {
|
||||
if acct == nil {
|
||||
return "", merrors.InvalidArgument("account is required")
|
||||
}
|
||||
@@ -137,7 +148,7 @@ func (s *service) CreateAccount(
|
||||
if err := s.accountDB.Create(tx, saved); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.VerifyAccount(tx, saved)
|
||||
return s.vdb.Create(tx, verification.NewLinkRequest(saved.ID, verificationmodel.PurposeAccountActivation, "").WithTTL(24*time.Hour).WithIdempotencyKey(key))
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, merrors.ErrDataConflict) {
|
||||
|
||||
@@ -36,6 +36,9 @@ type AccountService interface {
|
||||
ctx context.Context,
|
||||
acct *customermodel.Account,
|
||||
) (verificationToken string, err error)
|
||||
// CreateAccountWithActivationKey preserves atomic creation and lets the auth
|
||||
// service replay an unsent initial token. The key must be server-secret-derived.
|
||||
CreateAccountWithActivationKey(context.Context, *customermodel.Account, string) (string, error)
|
||||
|
||||
VerifyAccount(
|
||||
ctx context.Context,
|
||||
|
||||
Reference in new issue
Block a user