MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / UpdateUserEmail

Method UpdateUserEmail

auth/auth.go:617–640  ·  view source on GitHub ↗

Updates user email and writes user doc

(u User, email string)

Source from the content-addressed store, hash-verified

615
616// Updates user email and writes user doc
617func (auth *Authenticator) UpdateUserEmail(u User, email string) error {
618
619 updateUserEmailCallback := func(currentPrincipal Principal) (updatedPrincipal Principal, err error) {
620 currentUser, ok := currentPrincipal.(User)
621 if !ok {
622 return nil, base.ErrUpdateCancel
623 }
624
625 if currentUser.Email() == email {
626 return currentUser, base.ErrUpdateCancel
627 }
628
629 base.DebugfCtx(auth.LogCtx, base.KeyAuth, "Updating user %s email to: %v", base.UD(u.Name()), base.UD(email))
630 err = currentUser.SetEmail(email)
631 if err != nil {
632 return nil, err
633 }
634 currentUser.SetUpdatedAt()
635
636 return currentUser, nil
637 }
638
639 return auth.casUpdatePrincipal(u, updateUserEmailCallback)
640}
641
642// rehashPassword will check the bcrypt cost of the given hash
643// and will reset the user's password if the configured cost has since changed

Callers 2

TestConcurrentUserWritesFunction · 0.80

Calls 7

casUpdatePrincipalMethod · 0.95
DebugfCtxFunction · 0.92
UDFunction · 0.92
EmailMethod · 0.65
NameMethod · 0.65
SetEmailMethod · 0.65
SetUpdatedAtMethod · 0.65

Tested by 1

TestConcurrentUserWritesFunction · 0.64