From 328fc9cc89f32a3e83406dcbcd05037a42ec0539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 26 Jun 2020 10:42:22 +0300 Subject: [PATCH] #4497 apply DynamicStringLength for the user, identity and account modules. --- .../Volo/Abp/Account/RegisterDto.cs | 7 +++--- .../Pages/Account/Login.cshtml.cs | 4 ++-- .../Pages/Account/Manage.cshtml.cs | 18 ++++++++------- .../Pages/Account/Register.cshtml.cs | 7 +++--- .../IdentityRoleCreateOrUpdateDtoBase.cs | 3 ++- .../Abp/Identity/IdentityUserCreateDto.cs | 5 +++-- .../IdentityUserCreateOrUpdateDtoBase.cs | 11 +++++----- .../Abp/Identity/IdentityUserUpdateDto.cs | 3 ++- .../Volo/Abp/Identity/UpdateProfileDto.cs | 11 +++++----- .../Abp/Identity/IdentityClaimTypeConsts.cs | 10 ++++----- .../Abp/Identity/IdentityRoleClaimConsts.cs | 4 ++-- .../Volo/Abp/Identity/IdentityRoleConsts.cs | 6 ++--- .../Abp/Identity/IdentityUserClaimConsts.cs | 4 ++-- .../Volo/Abp/Identity/IdentityUserConsts.cs | 22 +++++++++---------- .../Abp/Identity/IdentityUserLoginConsts.cs | 6 ++--- .../Abp/Identity/IdentityUserTokenConsts.cs | 4 ++-- .../Abp/Identity/OrganizationUnitConsts.cs | 2 +- .../Identity/Roles/CreateModal.cshtml.cs | 3 ++- .../Pages/Identity/Roles/EditModal.cshtml.cs | 3 ++- .../Identity/Users/CreateModal.cshtml.cs | 13 ++++++----- .../Pages/Identity/Users/EditModal.cshtml.cs | 13 ++++++----- .../Volo/Abp/Users/AbpUserConsts.cs | 10 ++++----- 22 files changed, 91 insertions(+), 78 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs index 9a9f3caa4e..b69383d26f 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs @@ -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; } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs index 34a084bd3d..5251cb12f1 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -254,11 +254,11 @@ namespace Volo.Abp.Account.Web.Pages.Account 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; } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs index deed56b736..3c779dc870 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs @@ -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 { @@ -36,44 +37,45 @@ namespace Volo.Abp.Account.Web.Pages.Account 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; } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs index 87c7131305..f6d626dd63 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs @@ -9,6 +9,7 @@ using Volo.Abp.Application.Dtos; 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 @@ -74,16 +75,16 @@ namespace Volo.Abp.Account.Web.Pages.Account 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; } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleCreateOrUpdateDtoBase.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleCreateOrUpdateDtoBase.cs index 8e11d89b30..491e82d766 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleCreateOrUpdateDtoBase.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleCreateOrUpdateDtoBase.cs @@ -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; } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateDto.cs index a572c7db2c..a080a7e33e 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateDto.cs @@ -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; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs index c18f2c16b5..e06ea8b987 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs @@ -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; } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs index 216a55df9e..aa499bf2cd 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs @@ -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; } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs index 52919c7744..5e0397bdfa 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs @@ -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; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs index 32e3197e12..6e15cb0cfc 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleClaimConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleClaimConsts.cs index f53717486f..0f20ac40ef 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleClaimConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleClaimConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs index cac33aa53d..33e8e74977 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserClaimConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserClaimConsts.cs index 025b255f11..a850d6cff2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserClaimConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserClaimConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs index ef2cc57ef4..7b1a90dacc 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserLoginConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserLoginConsts.cs index 0ef43bb1b1..3f95dfd634 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserLoginConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserLoginConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserTokenConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserTokenConsts.cs index 92305851fb..1e4eb4794b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserTokenConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserTokenConsts.cs @@ -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; } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/OrganizationUnitConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/OrganizationUnitConsts.cs index ad6091a44e..7338fc8a28 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/OrganizationUnitConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/OrganizationUnitConsts.cs @@ -5,7 +5,7 @@ /// /// Maximum length of the property. /// - public const int MaxDisplayNameLength = 128; + public static int MaxDisplayNameLength { get; set; } = 128; /// /// Maximum depth of an OU hierarchy. diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs index e7244c80f1..df86acd94d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs @@ -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 { @@ -34,7 +35,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles public class RoleInfoModel { [Required] - [StringLength(IdentityRoleConsts.MaxNameLength)] + [DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))] [Display(Name = "DisplayName:RoleName")] public string Name { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs index 69305d243c..8a004e95a5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; 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 { @@ -44,7 +45,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles public string ConcurrencyStamp { get; set; } [Required] - [StringLength(IdentityRoleConsts.MaxNameLength)] + [DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))] [Display(Name = "DisplayName:RoleName")] public string Name { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index e7a1f4a26d..6149c676b8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Application.Dtos; +using Volo.Abp.Validation; namespace Volo.Abp.Identity.Web.Pages.Identity.Users { @@ -54,27 +55,27 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users public class UserInfoViewModel { [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] - [StringLength(IdentityUserConsts.MaxPasswordLength)] [DataType(DataType.Password)] [DisableAuditing] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] public string Password { 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; } = true; diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index f14ec21fe6..08c5ae0dd9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; +using Volo.Abp.Validation; namespace Volo.Abp.Identity.Web.Pages.Identity.Users { @@ -63,26 +64,26 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users public string ConcurrencyStamp { get; set; } [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; } - [StringLength(IdentityUserConsts.MaxPasswordLength)] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] [DataType(DataType.Password)] [DisableAuditing] public string Password { 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; } diff --git a/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs b/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs index acfce7f37b..ee37c6c9f4 100644 --- a/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs +++ b/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs @@ -2,14 +2,14 @@ namespace Volo.Abp.Users { public class AbpUserConsts { - public const int MaxUserNameLength = 256; + public static int MaxUserNameLength { get; set; } = 256; - public const int MaxNameLength = 64; + public static int MaxNameLength { get; set; } = 64; - public const int MaxSurnameLength = 64; + public static int MaxSurnameLength { get; set; } = 64; - public const int MaxEmailLength = 256; + public static int MaxEmailLength { get; set; } = 256; - public const int MaxPhoneNumberLength = 16; + public static int MaxPhoneNumberLength { get; set; } = 16; } } \ No newline at end of file