1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-03 23:51:21 +01:00

add missing string length checks

This commit is contained in:
Kyle Spearrin 2018-10-22 09:40:44 -04:00
parent 22033d075d
commit 84df4235c5
4 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,7 @@ namespace Bit.Core.Models.Api
public string Name { get; set; }
[Required]
public bool? AccessAll { get; set; }
[StringLength(300)]
public string ExternalId { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }

View File

@ -7,6 +7,7 @@ namespace Bit.Core.Models.Api
{
[Required]
[EmailAddress]
[StringLength(50)]
public string Email { get; set; }
public Installation ToInstallation()

View File

@ -14,8 +14,10 @@ namespace Bit.Core.Models.Api
public class Group
{
[Required]
[StringLength(100)]
public string Name { get; set; }
[Required]
[StringLength(300)]
public string ExternalId { get; set; }
public IEnumerable<string> Users { get; set; }
@ -39,9 +41,11 @@ namespace Bit.Core.Models.Api
public class User : IValidatableObject
{
[EmailAddress]
[StringLength(50)]
public string Email { get; set; }
public bool Deleted { get; set; }
[Required]
[StringLength(300)]
public string ExternalId { get; set; }
public ImportedOrganizationUser ToImportedOrganizationUser()

View File

@ -28,12 +28,17 @@ namespace Bit.Core.Models.Api
}
var attr = new EmailAddressAttribute();
for(int i = 0; i < Emails.Count(); i++)
for(var i = 0; i < Emails.Count(); i++)
{
if(!attr.IsValid(Emails.ElementAt(i)))
var email = Emails.ElementAt(i);
if(!attr.IsValid(email))
{
yield return new ValidationResult($"Email #{i + 1} is not valid.", new string[] { nameof(Emails) });
}
else if(email.Length > 50)
{
yield return new ValidationResult($"Email #{i + 1} is longer than 50 characters.", new string[] { nameof(Emails) });
}
}
}
}