mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
sync with user externalids
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Models.Business;
|
||||
using Bit.Core.Models.Table;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -18,25 +19,49 @@ namespace Bit.Core.Models.Api
|
||||
public string ExternalId { get; set; }
|
||||
public IEnumerable<string> Users { get; set; }
|
||||
|
||||
public Tuple<Table.Group, HashSet<string>> ToGroupTuple(Guid organizationId)
|
||||
public ImportedGroup ToImportedGroup(Guid organizationId)
|
||||
{
|
||||
var group = new Table.Group
|
||||
var importedGroup = new ImportedGroup
|
||||
{
|
||||
OrganizationId = organizationId,
|
||||
Name = Name,
|
||||
ExternalId = ExternalId
|
||||
Group = new Table.Group
|
||||
{
|
||||
OrganizationId = organizationId,
|
||||
Name = Name,
|
||||
ExternalId = ExternalId
|
||||
},
|
||||
ExternalUserIds = new HashSet<string>(Users)
|
||||
};
|
||||
|
||||
return new Tuple<Table.Group, HashSet<string>>(group, new HashSet<string>(Users));
|
||||
return importedGroup;
|
||||
}
|
||||
}
|
||||
|
||||
public class User
|
||||
public class User : IValidatableObject
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
[Required]
|
||||
public string ExternalId { get; set; }
|
||||
|
||||
public ImportedOrganizationUser ToImportedOrganizationUser()
|
||||
{
|
||||
var importedUser = new ImportedOrganizationUser
|
||||
{
|
||||
Email = Email,
|
||||
ExternalId = ExternalId
|
||||
};
|
||||
|
||||
return importedUser;
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Email) && !Disabled)
|
||||
{
|
||||
yield return new ValidationResult("Email is required for enabled users.", new string[] { nameof(Email) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
src/Core/Models/Business/ImportedGroup.cs
Normal file
11
src/Core/Models/Business/ImportedGroup.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Business
|
||||
{
|
||||
public class ImportedGroup
|
||||
{
|
||||
public Group Group { get; set; }
|
||||
public HashSet<string> ExternalUserIds { get; set; }
|
||||
}
|
||||
}
|
8
src/Core/Models/Business/ImportedOrganizationUser.cs
Normal file
8
src/Core/Models/Business/ImportedOrganizationUser.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Bit.Core.Models.Business
|
||||
{
|
||||
public class ImportedOrganizationUser
|
||||
{
|
||||
public string Email { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
}
|
@ -12,5 +12,6 @@ namespace Bit.Core.Models.Data
|
||||
public Enums.OrganizationUserStatusType Status { get; set; }
|
||||
public Enums.OrganizationUserType Type { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user