mirror of
https://github.com/bitwarden/server.git
synced 2025-02-10 00:51:22 +01:00
add missing string length checks
This commit is contained in:
parent
22033d075d
commit
84df4235c5
@ -13,6 +13,7 @@ namespace Bit.Core.Models.Api
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public bool? AccessAll { get; set; }
|
public bool? AccessAll { get; set; }
|
||||||
|
[StringLength(300)]
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ namespace Bit.Core.Models.Api
|
|||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
|
[StringLength(50)]
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
|
|
||||||
public Installation ToInstallation()
|
public Installation ToInstallation()
|
||||||
|
@ -14,8 +14,10 @@ namespace Bit.Core.Models.Api
|
|||||||
public class Group
|
public class Group
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
|
[StringLength(100)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[StringLength(300)]
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
public IEnumerable<string> Users { get; set; }
|
public IEnumerable<string> Users { get; set; }
|
||||||
|
|
||||||
@ -39,9 +41,11 @@ namespace Bit.Core.Models.Api
|
|||||||
public class User : IValidatableObject
|
public class User : IValidatableObject
|
||||||
{
|
{
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
|
[StringLength(50)]
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public bool Deleted { get; set; }
|
public bool Deleted { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[StringLength(300)]
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
|
|
||||||
public ImportedOrganizationUser ToImportedOrganizationUser()
|
public ImportedOrganizationUser ToImportedOrganizationUser()
|
||||||
|
@ -28,12 +28,17 @@ namespace Bit.Core.Models.Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
var attr = new EmailAddressAttribute();
|
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) });
|
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) });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user