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

Function NewUserWithPasswordHash

internal/models/user.go:77–105  ·  view source on GitHub ↗
(phone, email, passwordHash, aud string, userData map[string]interface{})

Source from the content-addressed store, hash-verified

75}
76
77func NewUserWithPasswordHash(phone, email, passwordHash, aud string, userData map[string]interface{}) (*User, error) {
78 if strings.HasPrefix(passwordHash, crypto.Argon2Prefix) {
79 _, err := crypto.ParseArgon2Hash(passwordHash)
80 if err != nil {
81 return nil, err
82 }
83 } else if strings.HasPrefix(passwordHash, crypto.FirebaseScryptPrefix) {
84 _, err := crypto.ParseFirebaseScryptHash(passwordHash)
85 if err != nil {
86 return nil, err
87 }
88 } else {
89 // verify that the hash is a bcrypt hash
90 _, err := bcrypt.Cost([]byte(passwordHash))
91 if err != nil {
92 return nil, err
93 }
94 }
95 id := uuid.Must(uuid.NewV4())
96 user := &User{
97 ID: id,
98 Aud: aud,
99 Email: storage.NullString(strings.ToLower(email)),
100 Phone: storage.NullString(phone),
101 UserMetaData: userData,
102 EncryptedPassword: &passwordHash,
103 }
104 return user, nil
105}
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) {

Calls 3

ParseArgon2HashFunction · 0.92
ParseFirebaseScryptHashFunction · 0.92
NullStringTypeAlias · 0.92