예제 #1
0
        private void ValidateUserLoginRequest(UserSignInRequest request)
        {
            ValidationException exception = new ValidationException();

            if (request == null)
            {
                exception.Add(new ValidationError("common.invalidRequest"));
            }

            if (string.IsNullOrWhiteSpace(request.Email))
            {
                exception.Add(new ValidationError("registration.signin.validation.emailRequired"));
            }

            if (string.IsNullOrWhiteSpace(request.Pwd))
            {
                exception.Add(new ValidationError("registration.signin.validation.pwdRequired"));
            }

            IUserRepository userRepository = IoC.Container.Resolve <IUserRepository>();
            User            userProfile    = userRepository.GetByEmail(request.Email);

            if (userProfile == null || EncodeHelper.EncodePassword(request.Pwd) != userProfile.Password)
            {
                exception.Add(new ValidationError("registration.signin.validation.invalidEmailOrPwd"));
            }

            exception.ThrowIfError();
        }