From a89bfdfe2b3193684d42c9bd1b702fed07765fc0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 15 Aug 2022 09:44:38 -0400 Subject: [PATCH] choose other emails when primary not available (#2188) --- bitwarden_license/src/Scim/Controllers/v2/UsersController.cs | 5 +++++ bitwarden_license/src/Scim/Models/BaseScimUserModel.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/bitwarden_license/src/Scim/Controllers/v2/UsersController.cs b/bitwarden_license/src/Scim/Controllers/v2/UsersController.cs index 3d3a91ca0c..0db35bc4d5 100644 --- a/bitwarden_license/src/Scim/Controllers/v2/UsersController.cs +++ b/bitwarden_license/src/Scim/Controllers/v2/UsersController.cs @@ -135,6 +135,11 @@ namespace Bit.Scim.Controllers.v2 email = model.UserName?.ToLowerInvariant(); break; default: + email = model.WorkEmail?.ToLowerInvariant(); + if (string.IsNullOrWhiteSpace(email)) + { + email = model.Emails?.FirstOrDefault()?.Value?.ToLowerInvariant(); + } break; } } diff --git a/bitwarden_license/src/Scim/Models/BaseScimUserModel.cs b/bitwarden_license/src/Scim/Models/BaseScimUserModel.cs index 53d94689c5..0af9e652b8 100644 --- a/bitwarden_license/src/Scim/Models/BaseScimUserModel.cs +++ b/bitwarden_license/src/Scim/Models/BaseScimUserModel.cs @@ -16,6 +16,7 @@ namespace Bit.Scim.Models public NameModel Name { get; set; } public List Emails { get; set; } public string PrimaryEmail => Emails?.FirstOrDefault(e => e.Primary)?.Value; + public string WorkEmail => Emails?.FirstOrDefault(e => e.Type == "work")?.Value; public string DisplayName { get; set; } public bool Active { get; set; } public List Groups { get; set; }