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

Method SetPassword

internal/models/user.go:329–352  ·  view source on GitHub ↗
(ctx context.Context, password string, encrypt bool, encryptionKeyID, encryptionKey string)

Source from the content-addressed store, hash-verified

327}
328
329func (u *User) SetPassword(ctx context.Context, password string, encrypt bool, encryptionKeyID, encryptionKey string) error {
330 if password == "" {
331 u.EncryptedPassword = nil
332 return nil
333 }
334
335 pw, err := crypto.GenerateFromPassword(ctx, password)
336 if err != nil {
337 return err
338 }
339
340 u.EncryptedPassword = &pw
341 if encrypt {
342 es, err := crypto.NewEncryptedString(u.ID.String(), []byte(pw), encryptionKeyID, encryptionKey)
343 if err != nil {
344 return err
345 }
346
347 encryptedPassword := es.String()
348 u.EncryptedPassword = &encryptedPassword
349 }
350
351 return nil
352}
353
354// UpdatePassword updates the user's password. Use SetPassword outside of a transaction first!
355func (u *User) UpdatePassword(tx *storage.Connection, sessionID *uuid.UUID) error {

Callers 5

AuthenticateMethod · 0.95
adminUserUpdateMethod · 0.80
signupVerifyMethod · 0.80
UserUpdateMethod · 0.80

Calls 4

StringMethod · 0.95
GenerateFromPasswordFunction · 0.92
NewEncryptedStringFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected