Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions internal/accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package accounts
import (
"context"
"errors"
"fmt"
"time"

"github.com/latebit-io/bulwarkauth/internal/tokens"
Expand Down Expand Up @@ -166,13 +167,18 @@ func (a DefaultAccountService) Register(ctx context.Context, tenantID, email str
}
err = a.accountRepository.Create(ctx, tenantID, email, password)
if err != nil {
return err
return errors.Join(fmt.Errorf("cannot create account for %s", email), err)
}
account, err := a.accountRepository.Read(ctx, tenantID, email)
if err != nil {
return err
return errors.Join(fmt.Errorf("failed to read account after creation %s", email), err)
}

err = a.emailService.SendVerificationEmail(ctx, tenantID, email, account.VerificationToken)
if err != nil {
return errors.Join(fmt.Errorf("cannot send verification email to %s", email), err)
}
return a.emailService.SendVerificationEmail(ctx, tenantID, email, account.VerificationToken)
return nil
}

// Verify when an account ot email is changed an account will need to be verified
Expand Down
Loading