Browse Source

#4497 apply DynamicStringLength for the user, identity and account modules.

pull/4500/head
Halil İbrahim Kalkan 6 years ago
parent
commit
328fc9cc89
  1. 7
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs
  2. 4
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs
  3. 18
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs
  4. 7
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs
  5. 3
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleCreateOrUpdateDtoBase.cs
  6. 5
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateDto.cs
  7. 11
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs
  8. 3
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs
  9. 11
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs
  10. 10
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs
  11. 4
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleClaimConsts.cs
  12. 6
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs
  13. 4
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserClaimConsts.cs
  14. 22
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs
  15. 6
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserLoginConsts.cs
  16. 4
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserTokenConsts.cs
  17. 2
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/OrganizationUnitConsts.cs
  18. 3
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs
  19. 3
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs
  20. 13
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs
  21. 13
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
  22. 10
      modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs

7
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/RegisterDto.cs

@ -1,22 +1,23 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.Validation;
namespace Volo.Abp.Account namespace Volo.Abp.Account
{ {
public class RegisterDto public class RegisterDto
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; } public string UserName { get; set; }
[Required] [Required]
[EmailAddress] [EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string EmailAddress { get; set; } public string EmailAddress { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[DisableAuditing] [DisableAuditing]
public string Password { get; set; } public string Password { get; set; }

4
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 public class LoginInputModel
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string UserNameOrEmailAddress { get; set; } public string UserNameOrEmailAddress { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[DisableAuditing] [DisableAuditing]
public string Password { get; set; } public string Password { get; set; }

18
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs

@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Validation;
namespace Volo.Abp.Account.Web.Pages.Account namespace Volo.Abp.Account.Web.Pages.Account
{ {
@ -36,44 +37,45 @@ namespace Volo.Abp.Account.Web.Pages.Account
public class ChangePasswordInfoModel public class ChangePasswordInfoModel
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[Display(Name = "DisplayName:CurrentPassword")] [Display(Name = "DisplayName:CurrentPassword")]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string CurrentPassword { get; set; } public string CurrentPassword { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[Display(Name = "DisplayName:NewPassword")] [Display(Name = "DisplayName:NewPassword")]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string NewPassword { get; set; } public string NewPassword { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[Display(Name = "DisplayName:NewPasswordConfirm")] [Display(Name = "DisplayName:NewPasswordConfirm")]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string NewPasswordConfirm { get; set; } public string NewPasswordConfirm { get; set; }
} }
public class PersonalSettingsInfoModel public class PersonalSettingsInfoModel
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
[Display(Name = "DisplayName:UserName")] [Display(Name = "DisplayName:UserName")]
public string UserName { get; set; } public string UserName { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
[Display(Name = "DisplayName:Email")] [Display(Name = "DisplayName:Email")]
public string Email { get; set; } public string Email { get; set; }
[StringLength(IdentityUserConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
[Display(Name = "DisplayName:Name")] [Display(Name = "DisplayName:Name")]
public string Name { get; set; } public string Name { get; set; }
[StringLength(IdentityUserConsts.MaxSurnameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
[Display(Name = "DisplayName:Surname")] [Display(Name = "DisplayName:Surname")]
public string Surname { get; set; } public string Surname { get; set; }
[StringLength(IdentityUserConsts.MaxPhoneNumberLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
[Display(Name = "DisplayName:PhoneNumber")] [Display(Name = "DisplayName:PhoneNumber")]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
} }

7
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.Identity;
using Volo.Abp.Settings; using Volo.Abp.Settings;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation;
using IdentityUser = Volo.Abp.Identity.IdentityUser; using IdentityUser = Volo.Abp.Identity.IdentityUser;
namespace Volo.Abp.Account.Web.Pages.Account namespace Volo.Abp.Account.Web.Pages.Account
@ -74,16 +75,16 @@ namespace Volo.Abp.Account.Web.Pages.Account
public class PostInput public class PostInput
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; } public string UserName { get; set; }
[Required] [Required]
[EmailAddress] [EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string EmailAddress { get; set; } public string EmailAddress { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[DisableAuditing] [DisableAuditing]
public string Password { get; set; } public string Password { get; set; }

3
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRoleCreateOrUpdateDtoBase.cs

@ -1,12 +1,13 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity
{ {
public class IdentityRoleCreateOrUpdateDtoBase : ExtensibleObject public class IdentityRoleCreateOrUpdateDtoBase : ExtensibleObject
{ {
[Required] [Required]
[StringLength(IdentityRoleConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))]
public string Name { get; set; } public string Name { get; set; }
public bool IsDefault { get; set; } public bool IsDefault { get; set; }

5
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateDto.cs

@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity
{ {
public class IdentityUserCreateDto : IdentityUserCreateOrUpdateDtoBase public class IdentityUserCreateDto : IdentityUserCreateOrUpdateDtoBase
{ {
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DisableAuditing] [DisableAuditing]
[Required]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
public string Password { get; set; } public string Password { get; set; }
} }
} }

11
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs

@ -2,27 +2,28 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using JetBrains.Annotations; using JetBrains.Annotations;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity
{ {
public abstract class IdentityUserCreateOrUpdateDtoBase : ExtensibleObject public abstract class IdentityUserCreateOrUpdateDtoBase : ExtensibleObject
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; } public string UserName { get; set; }
[StringLength(IdentityUserConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
public string Name { get; set; } public string Name { get; set; }
[StringLength(IdentityUserConsts.MaxSurnameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
public string Surname { get; set; } public string Surname { get; set; }
[Required] [Required]
[EmailAddress] [EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; } public string Email { get; set; }
[StringLength(IdentityUserConsts.MaxPhoneNumberLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
public bool TwoFactorEnabled { get; set; } public bool TwoFactorEnabled { get; set; }

3
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs

@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity
{ {
public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp
{ {
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DisableAuditing] [DisableAuditing]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
public string Password { get; set; } public string Password { get; set; }
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; }

11
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdateProfileDto.cs

@ -1,23 +1,24 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity
{ {
public class UpdateProfileDto : ExtensibleObject public class UpdateProfileDto : ExtensibleObject
{ {
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; } public string UserName { get; set; }
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; } public string Email { get; set; }
[StringLength(IdentityUserConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
public string Name { get; set; } public string Name { get; set; }
[StringLength(IdentityUserConsts.MaxSurnameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
public string Surname { get; set; } public string Surname { get; set; }
[StringLength(IdentityUserConsts.MaxPhoneNumberLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
} }
} }

10
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimTypeConsts.cs

@ -2,10 +2,10 @@
{ {
public class IdentityClaimTypeConsts public class IdentityClaimTypeConsts
{ {
public const int MaxNameLength = 256; public static int MaxNameLength { get; set; } = 256;
public const int MaxRegexLength = 512; public static int MaxRegexLength { get; set; } = 512;
public const int MaxRegexDescriptionLength = 128; public static int MaxRegexDescriptionLength { get; set; } = 128;
public const int MaxDescriptionLength = 256; public static int MaxDescriptionLength { get; set; } = 256;
public const int MaxConcurrencyStampLength = 256; public static int MaxConcurrencyStampLength { get; set; } = 256;
} }
} }

4
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleClaimConsts.cs

@ -2,8 +2,8 @@
{ {
public static class IdentityRoleClaimConsts 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;
} }
} }

6
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityRoleConsts.cs

@ -2,8 +2,8 @@
{ {
public static class IdentityRoleConsts public static class IdentityRoleConsts
{ {
public const int MaxNameLength = 256; public static int MaxNameLength { get; set; } = 256;
public const int MaxNormalizedNameLength = MaxNameLength; public static int MaxNormalizedNameLength { get; set; } = 256;
public const int MaxConcurrencyStampLength = 256; public static int MaxConcurrencyStampLength { get; set; } = 256;
} }
} }

4
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserClaimConsts.cs

@ -2,8 +2,8 @@
{ {
public static class IdentityUserClaimConsts 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;
} }
} }

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

6
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserLoginConsts.cs

@ -2,8 +2,8 @@
{ {
public static class IdentityUserLoginConsts public static class IdentityUserLoginConsts
{ {
public const int MaxLoginProviderLength = 64; public static int MaxLoginProviderLength { get; set; } = 64;
public const int MaxProviderKeyLength = 196; public static int MaxProviderKeyLength { get; set; } = 196;
public const int MaxProviderDisplayNameLength = 128; public static int MaxProviderDisplayNameLength { get; set; } = 128;
} }
} }

4
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserTokenConsts.cs

@ -2,8 +2,8 @@
{ {
public static class IdentityUserTokenConsts 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;
} }
} }

2
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/OrganizationUnitConsts.cs

@ -5,7 +5,7 @@
/// <summary> /// <summary>
/// Maximum length of the <see cref="DisplayName"/> property. /// Maximum length of the <see cref="DisplayName"/> property.
/// </summary> /// </summary>
public const int MaxDisplayNameLength = 128; public static int MaxDisplayNameLength { get; set; } = 128;
/// <summary> /// <summary>
/// Maximum depth of an OU hierarchy. /// Maximum depth of an OU hierarchy.

3
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
{ {
@ -34,7 +35,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
public class RoleInfoModel public class RoleInfoModel
{ {
[Required] [Required]
[StringLength(IdentityRoleConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))]
[Display(Name = "DisplayName:RoleName")] [Display(Name = "DisplayName:RoleName")]
public string Name { get; set; } public string Name { get; set; }

3
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 System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles 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; } public string ConcurrencyStamp { get; set; }
[Required] [Required]
[StringLength(IdentityRoleConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityRoleConsts), nameof(IdentityRoleConsts.MaxNameLength))]
[Display(Name = "DisplayName:RoleName")] [Display(Name = "DisplayName:RoleName")]
public string Name { get; set; } public string Name { get; set; }

13
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 Microsoft.AspNetCore.Mvc;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{ {
@ -54,27 +55,27 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
public class UserInfoViewModel public class UserInfoViewModel
{ {
[Required] [Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; } public string UserName { get; set; }
[StringLength(IdentityUserConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
public string Name { get; set; } public string Name { get; set; }
[StringLength(IdentityUserConsts.MaxSurnameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
public string Surname { get; set; } public string Surname { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[DisableAuditing] [DisableAuditing]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
public string Password { get; set; } public string Password { get; set; }
[Required] [Required]
[EmailAddress] [EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; } public string Email { get; set; }
[StringLength(IdentityUserConsts.MaxPhoneNumberLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
public bool TwoFactorEnabled { get; set; } = true; public bool TwoFactorEnabled { get; set; } = true;

13
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.Auditing;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Validation;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users 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; } public string ConcurrencyStamp { get; set; }
[Required] [Required]
[StringLength(IdentityUserConsts.MaxUserNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))]
public string UserName { get; set; } public string UserName { get; set; }
[StringLength(IdentityUserConsts.MaxNameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))]
public string Name { get; set; } public string Name { get; set; }
[StringLength(IdentityUserConsts.MaxSurnameLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))]
public string Surname { get; set; } public string Surname { get; set; }
[StringLength(IdentityUserConsts.MaxPasswordLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[DisableAuditing] [DisableAuditing]
public string Password { get; set; } public string Password { get; set; }
[Required] [Required]
[EmailAddress] [EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; } public string Email { get; set; }
[StringLength(IdentityUserConsts.MaxPhoneNumberLength)] [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
public bool TwoFactorEnabled { get; set; } public bool TwoFactorEnabled { get; set; }

10
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 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;
} }
} }
Loading…
Cancel
Save