RegisterViewModel.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections.Generic;
  2. using System.ComponentModel.DataAnnotations;
  3. using Abp.Auditing;
  4. using Abp.Extensions;
  5. using VberAdmin.Validation;
  6. using VberZero.BaseSystem.Users;
  7. namespace VberAdmin.Web.Models.Account;
  8. public class RegisterViewModel : IValidatableObject
  9. {
  10. [Required]
  11. [StringLength(User.MaxNameLength)]
  12. public string Name { get; set; }
  13. [Required]
  14. [StringLength(User.MaxSurnameLength)]
  15. public string Surname { get; set; }
  16. [StringLength(User.MaxUserNameLength)]
  17. public string UserName { get; set; }
  18. [Required]
  19. [EmailAddress]
  20. [StringLength(User.MaxEmailAddressLength)]
  21. public string EmailAddress { get; set; }
  22. [StringLength(User.MaxPlainPasswordLength)]
  23. [DisableAuditing]
  24. public string Password { get; set; }
  25. public bool IsExternalLogin { get; set; }
  26. public string ExternalLoginAuthSchema { get; set; }
  27. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  28. {
  29. if (!UserName.IsNullOrEmpty())
  30. {
  31. if (!UserName.Equals(EmailAddress) && ValidationHelper.IsEmail(UserName))
  32. {
  33. yield return new ValidationResult("Username cannot be an email address unless it's the same as your email address!");
  34. }
  35. }
  36. }
  37. }