コード例 #1
0
 private bool RegValidate(RegistrInfo registrInfo)
 {
     if (!IsEmailValid(registrInfo.Email))
     {
         throw new IncorrectRequestException("плохой адрес");
     }
     if (string.IsNullOrEmpty(registrInfo.Name))
     {
         throw new IncorrectRequestException("нет имени");
     }
     if (registrInfo.Name.Length < 3)
     {
         throw new IncorrectRequestException("короткое имя");
     }
     if (string.IsNullOrEmpty(registrInfo.Password))
     {
         throw new IncorrectRequestException("нет пароля");
     }
     if (string.IsNullOrEmpty(registrInfo.RePassword))
     {
         throw new IncorrectRequestException("нет второго пароля");
     }
     if (!string.Equals(registrInfo.Password, registrInfo.RePassword))
     {
         throw new IncorrectRequestException("не совпадают пароли");
     }
     registrInfo.Email = registrInfo.Email.ToLower();
     return(true);
 }
コード例 #2
0
        public void Handle(RegistrInfo registrInfo)
        {
            RegValidate(registrInfo);
            var user = _userService.GetUserFromTableUser(registrInfo.Email);

            if (user != null)
            {
                throw new IncorrectRequestException("Пользователь уже существует");
            }
            else
            {
                user          = new User();
                user.Email    = registrInfo.Email;
                user.Salt     = Password.GetSalt();
                user.HashPass = Password.GetHashPass(user.Salt, registrInfo.Password);
                _userService.InsertNewUser(user);
            }
        }
コード例 #3
0
ファイル: Registration.cs プロジェクト: oZFdad/modulServer
        public void RegisterUser(RegistrInfo registrInfo)
        {
            var regInfoRequestHandler = new RegInfoRequestHandler(new UserService());

            regInfoRequestHandler.Handle(registrInfo);
        }