1
0
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:
Kyle Spearrin
2017-05-16 00:11:21 -04:00
parent b3e4fcca74
commit 933a3feade
9 changed files with 108 additions and 39 deletions

View File

@ -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) });
}
}
}
}
}

View 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; }
}
}

View File

@ -0,0 +1,8 @@
namespace Bit.Core.Models.Business
{
public class ImportedOrganizationUser
{
public string Email { get; set; }
public string ExternalId { get; set; }
}
}

View File

@ -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; }
}
}