diff --git a/src/Api/Controllers/OrganizationUsersController.cs b/src/Api/Controllers/OrganizationUsersController.cs index 8f10f9d2d..2c5c08f11 100644 --- a/src/Api/Controllers/OrganizationUsersController.cs +++ b/src/Api/Controllers/OrganizationUsersController.cs @@ -58,7 +58,7 @@ namespace Bit.Api.Controllers public async Task Invite(string orgId, [FromBody]OrganizationUserInviteRequestModel model) { var userId = _userService.GetProperUserId(User); - var result = await _organizationService.InviteUserAsync(new Guid(orgId), userId.Value, model.Email, model.Type, + var result = await _organizationService.InviteUserAsync(new Guid(orgId), userId.Value, model.Email, model.Type.Value, model.Subvaults?.Select(s => s.ToSubvaultUser())); } diff --git a/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs b/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs index 7d9c41f8e..d9bfe59dc 100644 --- a/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs +++ b/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs @@ -1,40 +1,48 @@ using Bit.Core.Models.Table; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; namespace Bit.Core.Models.Api { public class OrganizationUserInviteRequestModel { + [Required] + [EmailAddress] public string Email { get; set; } - public Enums.OrganizationUserType Type { get; set; } + [Required] + public Enums.OrganizationUserType? Type { get; set; } public IEnumerable Subvaults { get; set; } } public class OrganizationUserAcceptRequestModel { + [Required] public string Token { get; set; } } public class OrganizationUserConfirmRequestModel { + [Required] public string Key { get; set; } } public class OrganizationUserUpdateRequestModel { - public Enums.OrganizationUserType Type { get; set; } + [Required] + public Enums.OrganizationUserType? Type { get; set; } public IEnumerable Subvaults { get; set; } public OrganizationUser ToOrganizationUser(OrganizationUser existingUser) { - existingUser.Type = Type; + existingUser.Type = Type.Value; return existingUser; } } public class OrganizationUserSubvaultRequestModel { + [Required] public string SubvaultId { get; set; } public bool Admin { get; set; } public bool ReadOnly { get; set; } @@ -44,14 +52,10 @@ namespace Bit.Core.Models.Api var subvault = new SubvaultUser { Admin = Admin, - ReadOnly = ReadOnly + ReadOnly = ReadOnly, + SubvaultId = new Guid(SubvaultId) }; - if(!string.IsNullOrWhiteSpace(SubvaultId)) - { - subvault.SubvaultId = new Guid(SubvaultId); - } - return subvault; } }