MCPcopy Create free account
hub / github.com/supabase/auth / shouldCreateUser

Method shouldCreateUser

internal/api/otp.go:211–238  ·  view source on GitHub ↗
(r *http.Request, params *OtpParams)

Source from the content-addressed store, hash-verified

209}
210
211func (a *API) shouldCreateUser(r *http.Request, params *OtpParams) (bool, error) {
212 ctx := r.Context()
213 db := a.db.WithContext(ctx)
214
215 if !params.CreateUser {
216 ctx := r.Context()
217 aud := a.requestAud(ctx, r)
218 var err error
219 if params.Email != "" {
220 params.Email, err = a.validateEmail(params.Email)
221 if err != nil {
222 return false, err
223 }
224 _, err = models.FindUserByEmailAndAudience(db, params.Email, aud)
225 } else if params.Phone != "" {
226 params.Phone, err = validatePhone(params.Phone)
227 if err != nil {
228 return false, err
229 }
230 _, err = models.FindUserByPhoneAndAudience(db, params.Phone, aud)
231 }
232
233 if err != nil && models.IsNotFoundError(err) {
234 return false, nil
235 }
236 }
237 return true, nil
238}

Callers 1

OtpMethod · 0.95

Calls 7

requestAudMethod · 0.95
validateEmailMethod · 0.95
IsNotFoundErrorFunction · 0.92
validatePhoneFunction · 0.85
WithContextMethod · 0.80

Tested by

no test coverage detected