Example #1
0
 public MenuBuilderFactory(IActionContextAccessor actionContextAccessor, IUrlHelperFactory urlHelperFactory
                           , IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUserAccessor)
 {
     _actionContextAccessor = actionContextAccessor;
     _urlHelperFactory      = urlHelperFactory;
     _unitOfWork            = unitOfWork;
     _loggedUserAccessor    = loggedUserAccessor;
 }
Example #2
0
        protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
        {
            var user = unitOfWork.Users.GetByEmailOrNull(Email);

            if (user == null)
            {
                yield return(new ValidationResult("The email address could not be found.", new[] { nameof(Email) }));
            }
        }
Example #3
0
        protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
        {
            var user = unitOfWork.Users.GetWithRolesOrNull(loggedUser.Id);

            if (!PasswordHash.ValidatePassword(OldPassword, user.Password))
            {
                yield return(new ValidationResult("The current password is incorrect", new[] { this.GetPropertyName(m => m.OldPassword) }));
            }
        }
Example #4
0
 protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
 {
     if (!string.Equals(loggedUser.Claims.Login, Login, StringComparison.OrdinalIgnoreCase))
     {
         var byLogin = unitOfWork.Users.GetByLoginOrNull(Login, true);
         if (byLogin != null && byLogin.Id != loggedUser.Id)
         {
             yield return(new ValidationResult("Login already in use.", new[] { this.GetPropertyName(m => m.Login) }));
         }
     }
 }
 protected MenuBuilderBase(MenuBuilderArgs args)
 {
     UrlFactory = new MenuUrlFactory(args.MenuMvcArgs);
     UnitOfWork = args.UnitOfWork;
     LoggedUser = args.LoggedUser;
 }
 public MenuBuilderArgs(MenuMvcArgs menuMvcArgs, IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser)
 {
     MenuMvcArgs = menuMvcArgs;
     UnitOfWork  = unitOfWork;
     LoggedUser  = loggedUser;
 }
Example #7
0
        protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
        {
            if (Roles == null || !Roles.Any())
            {
                yield return(new ValidationResult("At least one role required.", new[] { this.GetPropertyName(m => m.Roles) }));
            }

            var userByLogin = unitOfWork.Users.GetByLoginOrNull(Login, true);

            if ((userByLogin != null) && (userByLogin.Id != Id))
            {
                yield return(new ValidationResult("User name already in use.", new[] { this.GetPropertyName(m => m.Login) }));
            }

            var userByEmail = unitOfWork.Users.GetByEmailOrNull(Email, true);

            if ((userByEmail != null) && (userByEmail.Id != Id))
            {
                yield return(new ValidationResult("Email already in use.", new[] { this.GetPropertyName(m => m.Email) }));
            }
        }
 protected abstract IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext);
Example #9
0
 protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
 {
     if (UserId < 0)
     {
         yield return(new ValidationResult($"UserId cannot be lower 0. UserId - {UserId}", new[] { nameof(UserId) }));
     }
 }
Example #10
0
 protected override IEnumerable <ValidationResult> Validate(IUnitOfWork unitOfWork, ILoggedUserAccessor loggedUser, ValidationContext validationContext)
 {
     AccountAfterValidation = unitOfWork.Users.GetAccountByLoginOrNull(UserName);
     return(ValidateUser(AccountAfterValidation, Password));
 }