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

Load more emails from SSO users #43

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
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
27 changes: 22 additions & 5 deletions pkg/connector/sso_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,32 @@ func (o *ssoUserResourceType) List(ctx context.Context, _ *v2.ResourceId, pt *pa
Id: userARN,
}
profile := ssoUserProfile(ctx, user)
emailFromUsername := getSsoUserEmail(user)
userOptions := []resourceSdk.UserTraitOption{
resourceSdk.WithUserProfile(profile),
resourceSdk.WithStatus(status),
}
foundPrimaryEmail := false
if emailFromUsername != "" {
userOptions = append(userOptions, resourceSdk.WithEmail(emailFromUsername, true))
foundPrimaryEmail = true
}
for _, email := range user.Emails {
if email.Value == nil {
continue
}
// If we haven't already found an email, make this one primary, otherwise it's non-primary
userOptions = append(userOptions, resourceSdk.WithEmail(*email.Value, !foundPrimaryEmail))
// If this is our first primary email, mark it as such
if !foundPrimaryEmail {
foundPrimaryEmail = true
}
}
userResource, err := resourceSdk.NewUserResource(
awsSdk.ToString(user.UserName),
resourceTypeSSOUser,
userARN,
[]resourceSdk.UserTraitOption{
resourceSdk.WithEmail(getSsoUserEmail(user), true),
resourceSdk.WithUserProfile(profile),
resourceSdk.WithStatus(status),
},
userOptions,
resourceSdk.WithAnnotation(annos),
)
if err != nil {
Expand Down
Loading