Skip to content

Commit

Permalink
#4497 apply DynamicStringLength for the user, identity and account mo…
Browse files Browse the repository at this point in the history
…dules.
  • Loading branch information
hikalkan committed Jun 26, 2020
1 parent fe48574 commit 328fc9c
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing;
using Volo.Abp.Identity;
using Volo.Abp.Validation;

namespace Volo.Abp.Account
{
public class RegisterDto
{
[Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; }

[Required]
[EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string EmailAddress { get; set; }

[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)]
[DisableAuditing]
public string Password { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ protected virtual async Task CheckLocalLoginAsync()
public class LoginInputModel
{
[Required]
[StringLength(IdentityUserConsts.MaxEmailLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string UserNameOrEmailAddress { get; set; }

[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)]
[DisableAuditing]
public string Password { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Volo.Abp.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Validation;

namespace Volo.Abp.Account.Web.Pages.Account
{
Expand Down Expand Up @@ -36,44 +37,45 @@ public virtual Task<IActionResult> OnPostAsync()
public class ChangePasswordInfoModel
{
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[Display(Name = "DisplayName:CurrentPassword")]
[DataType(DataType.Password)]
public string CurrentPassword { get; set; }

[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[Display(Name = "DisplayName:NewPassword")]
[DataType(DataType.Password)]
public string NewPassword { get; set; }

[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[Display(Name = "DisplayName:NewPasswordConfirm")]
[DataType(DataType.Password)]
public string NewPasswordConfirm { get; set; }
}

public class PersonalSettingsInfoModel
{
[Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
[Display(Name = "DisplayName:UserName")]
public string UserName { get; set; }

[Required]
[StringLength(IdentityUserConsts.MaxEmailLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
[Display(Name = "DisplayName:Email")]
public string Email { get; set; }

[StringLength(IdentityUserConsts.MaxNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
[Display(Name = "DisplayName:Name")]
public string Name { get; set; }

[StringLength(IdentityUserConsts.MaxSurnameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
[Display(Name = "DisplayName:Surname")]
public string Surname { get; set; }

[StringLength(IdentityUserConsts.MaxPhoneNumberLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
[Display(Name = "DisplayName:PhoneNumber")]
public string PhoneNumber { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Volo.Abp.Identity;
using Volo.Abp.Settings;
using Volo.Abp.Uow;
using Volo.Abp.Validation;
using IdentityUser = Volo.Abp.Identity.IdentityUser;

namespace Volo.Abp.Account.Web.Pages.Account
Expand Down Expand Up @@ -74,16 +75,16 @@ protected virtual async Task CheckSelfRegistrationAsync()
public class PostInput
{
[Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; }

[Required]
[EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string EmailAddress { get; set; }

[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)]
[DisableAuditing]
public string Password { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity
{
public class IdentityRoleCreateOrUpdateDtoBase : ExtensibleObject
{
[Required]
[StringLength(IdentityRoleConsts.MaxNameLength)]
[DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))]
public string Name { get; set; }

public bool IsDefault { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity
{
public class IdentityUserCreateDto : IdentityUserCreateOrUpdateDtoBase
{
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DisableAuditing]
[Required]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
public string Password { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
using System.ComponentModel.DataAnnotations;
using JetBrains.Annotations;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity
{
public abstract class IdentityUserCreateOrUpdateDtoBase : ExtensibleObject
{
[Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; }

[StringLength(IdentityUserConsts.MaxNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
public string Name { get; set; }

[StringLength(IdentityUserConsts.MaxSurnameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
public string Surname { get; set; }

[Required]
[EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; }

[StringLength(IdentityUserConsts.MaxPhoneNumberLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
public string PhoneNumber { get; set; }

public bool TwoFactorEnabled { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity
{
public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp
{
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DisableAuditing]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
public string Password { get; set; }

public string ConcurrencyStamp { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity
{
public class UpdateProfileDto : ExtensibleObject
{
[StringLength(IdentityUserConsts.MaxUserNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; }

[StringLength(IdentityUserConsts.MaxEmailLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; }

[StringLength(IdentityUserConsts.MaxNameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
public string Name { get; set; }

[StringLength(IdentityUserConsts.MaxSurnameLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
public string Surname { get; set; }

[StringLength(IdentityUserConsts.MaxPhoneNumberLength)]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
public string PhoneNumber { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
public class IdentityClaimTypeConsts
{
public const int MaxNameLength = 256;
public const int MaxRegexLength = 512;
public const int MaxRegexDescriptionLength = 128;
public const int MaxDescriptionLength = 256;
public const int MaxConcurrencyStampLength = 256;
public static int MaxNameLength { get; set; } = 256;
public static int MaxRegexLength { get; set; } = 512;
public static int MaxRegexDescriptionLength { get; set; } = 128;
public static int MaxDescriptionLength { get; set; } = 256;
public static int MaxConcurrencyStampLength { get; set; } = 256;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public static class IdentityRoleClaimConsts
{
public const int MaxClaimTypeLength = IdentityUserClaimConsts.MaxClaimTypeLength;
public static int MaxClaimTypeLength { get; set; } = IdentityUserClaimConsts.MaxClaimTypeLength;

public const int MaxClaimValueLength = IdentityUserClaimConsts.MaxClaimValueLength;
public static int MaxClaimValueLength { get; set; } = IdentityUserClaimConsts.MaxClaimValueLength;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public static class IdentityRoleConsts
{
public const int MaxNameLength = 256;
public const int MaxNormalizedNameLength = MaxNameLength;
public const int MaxConcurrencyStampLength = 256;
public static int MaxNameLength { get; set; } = 256;
public static int MaxNormalizedNameLength { get; set; } = 256;
public static int MaxConcurrencyStampLength { get; set; } = 256;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public static class IdentityUserClaimConsts
{
public const int MaxClaimTypeLength = 256;
public static int MaxClaimTypeLength { get; set; } = 256;

public const int MaxClaimValueLength = 1024;
public static int MaxClaimValueLength { get; set; } = 1024;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ namespace Volo.Abp.Identity
{
public static class IdentityUserConsts
{
public const int MaxUserNameLength = AbpUserConsts.MaxUserNameLength;
public static int MaxUserNameLength { get; set; } = AbpUserConsts.MaxUserNameLength;

public const int MaxNameLength = AbpUserConsts.MaxNameLength;
public static int MaxNameLength { get; set; } = AbpUserConsts.MaxNameLength;

public const int MaxSurnameLength = AbpUserConsts.MaxSurnameLength;
public static int MaxSurnameLength { get; set; } = AbpUserConsts.MaxSurnameLength;

public const int MaxNormalizedUserNameLength = MaxUserNameLength;
public static int MaxNormalizedUserNameLength { get; set; } = MaxUserNameLength;

public const int MaxEmailLength = AbpUserConsts.MaxEmailLength;
public static int MaxEmailLength { get; set; } = AbpUserConsts.MaxEmailLength;

public const int MaxNormalizedEmailLength = MaxEmailLength;
public static int MaxNormalizedEmailLength { get; set; } = MaxEmailLength;

public const int MaxPhoneNumberLength = AbpUserConsts.MaxPhoneNumberLength;
public static int MaxPhoneNumberLength { get; set; } = AbpUserConsts.MaxPhoneNumberLength;

public const int MaxPasswordLength = 128;
public static int MaxPasswordLength { get; set; } = 128;

public const int MaxPasswordHashLength = 256;
public static int MaxPasswordHashLength { get; set; } = 256;

public const int MaxSecurityStampLength = 256;
public static int MaxSecurityStampLength { get; set; } = 256;

public const int MaxConcurrencyStampLength = 256;
public static int MaxConcurrencyStampLength { get; set; } = 256;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public static class IdentityUserLoginConsts
{
public const int MaxLoginProviderLength = 64;
public const int MaxProviderKeyLength = 196;
public const int MaxProviderDisplayNameLength = 128;
public static int MaxLoginProviderLength { get; set; } = 64;
public static int MaxProviderKeyLength { get; set; } = 196;
public static int MaxProviderDisplayNameLength { get; set; } = 128;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public static class IdentityUserTokenConsts
{
public const int MaxLoginProviderLength = 64;
public static int MaxLoginProviderLength { get; set; } = 64;

public const int MaxNameLength = 128;
public static int MaxNameLength { get; set; } = 128;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public static class OrganizationUnitConsts
/// <summary>
/// Maximum length of the <see cref="DisplayName"/> property.
/// </summary>
public const int MaxDisplayNameLength = 128;
public static int MaxDisplayNameLength { get; set; } = 128;

/// <summary>
/// Maximum depth of an OU hierarchy.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
{
Expand Down Expand Up @@ -34,7 +35,7 @@ public virtual async Task<IActionResult> OnPostAsync()
public class RoleInfoModel
{
[Required]
[StringLength(IdentityRoleConsts.MaxNameLength)]
[DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))]
[Display(Name = "DisplayName:RoleName")]
public string Name { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;

namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public class RoleInfoModel : IHasConcurrencyStamp
public string ConcurrencyStamp { get; set; }

[Required]
[StringLength(IdentityRoleConsts.MaxNameLength)]
[DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))]
[Display(Name = "DisplayName:RoleName")]
public string Name { get; set; }

Expand Down
Loading

0 comments on commit 328fc9c

Please sign in to comment.