(ctx context.Context, iamManager *iam.Manager, user *store.UserMessage)
| 715 | } |
| 716 | |
| 717 | func convertToUser(ctx context.Context, iamManager *iam.Manager, user *store.UserMessage) (*v1pb.User, error) { |
| 718 | groups, err := iamManager.GetUserGroups(ctx, common.GetWorkspaceIDFromContext(ctx), user.Email) |
| 719 | if err != nil { |
| 720 | return nil, err |
| 721 | } |
| 722 | |
| 723 | workspaceID := common.GetWorkspaceIDFromContext(ctx) |
| 724 | convertedUser := &v1pb.User{ |
| 725 | Name: common.FormatUserEmail(user.Email), |
| 726 | State: convertDeletedToState(user.MemberDeleted), |
| 727 | Email: user.Email, |
| 728 | Phone: user.Phone, |
| 729 | Title: user.Name, |
| 730 | Profile: &v1pb.User_Profile{ |
| 731 | LastLoginTime: user.Profile.LastLoginTime, |
| 732 | LastChangePasswordTime: user.Profile.LastChangePasswordTime, |
| 733 | Source: user.Profile.Source, |
| 734 | }, |
| 735 | Groups: groups, |
| 736 | Workspace: common.FormatWorkspace(workspaceID), |
| 737 | } |
| 738 | |
| 739 | if user.MFAConfig != nil { |
| 740 | convertedUser.MfaEnabled = user.MFAConfig.OtpSecret != "" |
| 741 | // Only expose temporary MFA secrets and recovery codes to the user themselves |
| 742 | if currentUser, ok := GetUserFromContext(ctx); ok && currentUser.ID == user.ID { |
| 743 | convertedUser.TempOtpSecret = user.MFAConfig.TempOtpSecret |
| 744 | convertedUser.TempRecoveryCodes = user.MFAConfig.TempRecoveryCodes |
| 745 | convertedUser.TempOtpSecretCreatedTime = user.MFAConfig.TempOtpSecretCreatedTime |
| 746 | } |
| 747 | } |
| 748 | return convertedUser, nil |
| 749 | } |
| 750 | |
| 751 | func validateEndUserEmail(email string) error { |
| 752 | if common.IsServiceAccountEmail(email) { |
no test coverage detected