Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4404] Bug/LF Search by Email #4405

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cla-backend-go/v2/cla_manager/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (s *service) CreateCLAManager(ctx context.Context, authUser *auth.User, cla
msg := fmt.Sprintf("Failed to get Lfx User with username : %s ", authUsername)
log.WithFields(f).Warn(msg)
}
user, userErr := userServiceClient.SearchUserByEmail(params.Body.UserEmail.String())
user, userErr := userServiceClient.SearchUsersByEmail(params.Body.UserEmail.String())

// Check for potential user with no username
if user != nil && user.Username == "" {
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func (s *service) InviteCompanyAdmin(ctx context.Context, contactAdmin bool, com
}

// Get suggested CLA Manager user details
user, userErr := userService.SearchUserByEmail(userEmail)
user, userErr := userService.SearchUsersByEmail(userEmail)
if userErr != nil || (user != nil && user.Username == "") {
var contributorModel emails.Contributor
msg := fmt.Sprintf("UserEmail: %s has no LF Login and has been sent an invite email to create an account , error: %+v", userEmail, userErr)
Expand Down
6 changes: 3 additions & 3 deletions cla-backend-go/v2/company/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func (s *service) CreateCompany(ctx context.Context, params *v2Ops.CreateCompany
acsClient := acsService.GetClient()
userClient := v2UserService.GetClient()

lfUser, lfErr := userClient.SearchUserByEmail(userEmail)
lfUser, lfErr := userClient.SearchUsersByEmail(userEmail)
if lfErr != nil {
msg := fmt.Sprintf("User : %s has no LFID", userEmail)
log.WithFields(f).Warn(msg)
Expand Down Expand Up @@ -666,7 +666,7 @@ func (s *service) AssociateContributor(ctx context.Context, companySFID string,

userService := v2UserService.GetClient()
log.WithFields(f).Info("searching for LFX User")
lfxUser, userErr := userService.SearchUserByEmail(userEmail)
lfxUser, userErr := userService.SearchUsersByEmail(userEmail)
if userErr != nil {
log.WithFields(f).Warnf("unable to get user")
return nil, userErr
Expand Down Expand Up @@ -715,7 +715,7 @@ func (s *service) CreateContributor(ctx context.Context, companyID string, proje
acServiceClient := acsService.GetClient()
orgClient := orgService.GetClient()

user, userErr := userClient.SearchUserByEmail(userEmail)
user, userErr := userClient.SearchUsersByEmail(userEmail)
if userErr != nil {
log.WithFields(f).Debugf("Failed to get user by email: %s , error: %+v", userEmail, userErr)
return nil, ErrLFXUserNotFound
Expand Down
4 changes: 2 additions & 2 deletions cla-backend-go/v2/dynamo_events/cla_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *service) SetInitialCLAManagerACSPermissions(ctx context.Context, signat

log.WithFields(f).Debugf("searching user by email: %s", sig.SignatureACL[0].LfEmail)
if sig.SignatureACL[0].LfEmail != "" {
claManager, err = userServiceClient.SearchUserByEmail(sig.SignatureACL[0].LfEmail.String())
claManager, err = userServiceClient.SearchUsersByEmail(sig.SignatureACL[0].LfEmail.String())
if err != nil || claManager == nil {
log.WithFields(f).Warnf("unable to lookup user by email: %s, error: %+v",
sig.SignatureACL[0].LfEmail, err)
Expand All @@ -79,7 +79,7 @@ func (s *service) SetInitialCLAManagerACSPermissions(ctx context.Context, signat
// Search each one...
for _, altEmail := range sig.SignatureACL[0].Emails {
log.WithFields(f).Debugf("searching user by alternate email: %s", altEmail)
claManager, err = userServiceClient.SearchUserByEmail(altEmail)
claManager, err = userServiceClient.SearchUsersByEmail(altEmail)
if err != nil || claManager == nil {
log.WithFields(f).Warnf("unable to lookup user by alternate email: %s, error: %+v",
altEmail, err)
Expand Down
4 changes: 2 additions & 2 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@ func removeSignatoryRole(ctx context.Context, userEmail string, companySFID stri
usc := userService.GetClient()
// search user
log.WithFields(f).Debug("searching user by email")
user, err := usc.SearchUserByEmail(userEmail)
user, err := usc.SearchUsersByEmail(userEmail)
if err != nil {
log.WithFields(f).Debug("Failed to get user")
return err
Expand Down Expand Up @@ -2699,7 +2699,7 @@ func prepareUserForSigning(ctx context.Context, userEmail string, companySFID, p
usc := userService.GetClient()
// search user
log.WithFields(f).Debug("searching user by email")
user, err := usc.SearchUserByEmail(userEmail)
user, err := usc.SearchUsersByEmail(userEmail)
if err != nil {
log.WithFields(f).WithError(err).Debugf("User with email: %s does not have an LF login", userEmail)
return nil
Expand Down
30 changes: 0 additions & 30 deletions cla-backend-go/v2/user-service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,36 +340,6 @@ func getUsers(body []byte) ([]*models.User, error) {
return users.Data, err
}

// SearchUserByEmail search user by email
func (usc *Client) SearchUserByEmail(email string) (*models.User, error) {
f := logrus.Fields{
"functionName": "SearchUserByEmail",
"email": email,
}
params := &user.SearchUsersParams{
Email: &email,
Context: context.Background(),
}
tok, err := token.GetToken()
if err != nil {
log.WithFields(f).WithError(err).Warn("problem obtaining token")
return nil, err
}
clientAuth := runtimeClient.BearerToken(tok)
result, err := usc.cl.User.SearchUsers(params, clientAuth)
if err != nil {
log.WithFields(f).WithError(err).Warn("problem finding user by email")
return nil, err
}
users := result.Payload.Data

if len(users) == 0 {
log.WithFields(f).Debug("get by lfUsername returned no results")
return nil, ErrUserNotFound
}
return users[0], nil
}

// ConvertToContact converts user to contact from lead
func (usc *Client) ConvertToContact(userSFID string) error {
params := &user.ConvertToContactParams{
Expand Down
Loading