(ctx context.Context, p *SignupParams)
| 30 | } |
| 31 | |
| 32 | func (a *API) validateSignupParams(ctx context.Context, p *SignupParams) error { |
| 33 | config := a.config |
| 34 | |
| 35 | if p.Password == "" { |
| 36 | return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "Signup requires a valid password") |
| 37 | } |
| 38 | |
| 39 | if err := a.checkPasswordStrength(ctx, p.Password); err != nil { |
| 40 | return err |
| 41 | } |
| 42 | if p.Email != "" && p.Phone != "" { |
| 43 | return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "Only an email address or phone number should be provided on signup.") |
| 44 | } |
| 45 | if p.Provider == "phone" && !sms_provider.IsValidMessageChannel(p.Channel, config) { |
| 46 | return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, InvalidChannelError) |
| 47 | } |
| 48 | // PKCE not needed as phone signups already return access token in body |
| 49 | if p.Phone != "" && p.CodeChallenge != "" { |
| 50 | return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "PKCE not supported for phone signups") |
| 51 | } |
| 52 | if err := validatePKCEParams(p.CodeChallengeMethod, p.CodeChallenge); err != nil { |
| 53 | return err |
| 54 | } |
| 55 | |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func (p *SignupParams) ConfigureDefaults() { |
| 60 | if p.Email != "" { |
no test coverage detected