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

Function NewUser

internal/models/user.go:108–134  ·  view source on GitHub ↗

NewUser initializes a new user from an email, password and user data.

(phone, email, password, aud string, userData map[string]interface{})

Source from the content-addressed store, hash-verified

106
107// NewUser initializes a new user from an email, password and user data.
108func NewUser(phone, email, password, aud string, userData map[string]interface{}) (*User, error) {
109 passwordHash := ""
110
111 if password != "" {
112 pw, err := crypto.GenerateFromPassword(context.Background(), password)
113 if err != nil {
114 return nil, err
115 }
116
117 passwordHash = pw
118 }
119
120 if userData == nil {
121 userData = make(map[string]interface{})
122 }
123
124 id := uuid.Must(uuid.NewV4())
125 user := &User{
126 ID: id,
127 Aud: aud,
128 Email: storage.NullString(strings.ToLower(email)),
129 Phone: storage.NullString(phone),
130 UserMetaData: userData,
131 EncryptedPassword: &passwordHash,
132 }
133 return user, nil
134}
135
136// TableName overrides the table name used by pop
137func (User) TableName() string {

Callers 15

SetupTestMethod · 0.92
SetupTestMethod · 0.92
SetupTestMethod · 0.92
createBannedUserMethod · 0.92
SetupTestMethod · 0.92
SetupTestMethod · 0.92
SetupTestMethod · 0.92
TestUserUpdateEmailMethod · 0.92

Calls 2

GenerateFromPasswordFunction · 0.92
NullStringTypeAlias · 0.92

Tested by 15

SetupTestMethod · 0.74
SetupTestMethod · 0.74
SetupTestMethod · 0.74
createBannedUserMethod · 0.74
SetupTestMethod · 0.74
SetupTestMethod · 0.74
SetupTestMethod · 0.74
TestUserUpdateEmailMethod · 0.74